Page MenuHomePhabricator

[PowerPC] Fix the unexpected modification caused by D62993 in LowerSELECT_CC for power9
ClosedPublic

Authored by ZhangKang on Feb 17 2020, 12:52 AM.

Details

Summary

The patch D62993 : [PowerPC] Emit scalar min/max instructions with unsafe fp math has modified the functionality when Subtarget.hasP9Vector() && (!HasNoInfs || !HasNoNaNs), this modification is not expected.

For below case:

define double @test(double %a, double %b, double %c, double %d) {
entry:
  %cmp = fcmp fast oeq double %a, %b
  %cond = select fast i1 %cmp, double %c, double %d
  ret double %cond
}

Use the below command for pwr9 without the fast-math option,

llc -ppc-vsr-nums-as-vr -ppc-asm-full-reg-names test.ll -o p9.s -mcpu=pwr9 -O3

we will get below assembly, this is not right, because we haven't used the fast-math option :

asm
	xssubdp f0, f1, f2
	fsel f1, f0, f3, f4
	xsnegdp f0, f0
	fsel f1, f0, f1, f4
	blr

But in fact, if without the patch D62993, above case we will get below assembly, this is the right:

# %bb.0:                                # %entry
	xscmpudp cr0, f1, f2
	beq	cr0, .LBB0_2
# %bb.1:                                # %entry
	fmr f3, f4
.LBB0_2:                                # %entry
	fmr f1, f3
	blr

Diff Detail

Event Timeline

ZhangKang created this revision.Feb 17 2020, 12:52 AM
ZhangKang edited the summary of this revision. (Show Details)Feb 17 2020, 12:53 AM
ZhangKang added reviewers: Restricted Project, hfinkel.Feb 17 2020, 12:56 AM
ZhangKang added a subscriber: power-llvm-team.

@nemanjai , do you have any comments for this patch?

nemanjai accepted this revision.Feb 25 2020, 7:37 AM

LGTM. Sorry I missed this for so long. Thank you for fixing it.

This revision is now accepted and ready to land.Feb 25 2020, 7:37 AM
This revision was automatically updated to reflect the committed changes.