This is an archive of the discontinued LLVM Phabricator instance.

[Power] Set the mayRaiseFPException for FCMPUS/FCMPUD
ClosedPublic

Authored by steven.zhang on Jul 16 2020, 3:22 AM.

Details

Summary

From ISA, fcmpu will raise the Floating-Point Invalid Operation Exception (SNaN) if either of the operands is a Signaling NaN by setting the bit VXSNAN. But the instruction description didn't set the mayRaiseFPException which might have impact on the scheduling or some backend optimization.

Diff Detail

Event Timeline

steven.zhang created this revision.Jul 16 2020, 3:22 AM
qiucf added a comment.Jul 22 2020, 8:30 PM

Can we add test to show the effect? Something like

%a = call double @llvm.experimental.constrained.fadd.f64(...)
; Insert the instruction here
%b = call double @llvm.experimental.constrained.fdiv.f64(...)

I think instruction with side effect should prevent fdiv from scheduled upwards.

qiucf added a comment.Sep 1 2020, 8:52 PM
define i32 @test(double %a, double %b) {
entry:
  %r = fcmp ogt double %a, %b
  %g = zext i1 %r to i32
  ret i32 %g
}

Print MIR:

renamable $cr0 = FCMPUD killed renamable $f1, killed renamable $f2 # Without mayRaise set
renamable $cr0 = nofpexcept FCMPUD killed renamable $f1, killed renamable $f2 # With mayRaise set

You can create a dedicated test file for fp-exception bit, so that we can re-check all fp-exception bits in instruction definitions.

steven.zhang planned changes to this revision.Sep 3 2020, 2:50 AM
define i32 @test(double %a, double %b) {
entry:
  %r = fcmp ogt double %a, %b
  %g = zext i1 %r to i32
  ret i32 %g
}

Print MIR:

renamable $cr0 = FCMPUD killed renamable $f1, killed renamable $f2 # Without mayRaise set
renamable $cr0 = nofpexcept FCMPUD killed renamable $f1, killed renamable $f2 # With mayRaise set

You can create a dedicated test file for fp-exception bit, so that we can re-check all fp-exception bits in instruction definitions.

Thanks for the comments. I will update it.

qiucf accepted this revision as: qiucf.Sep 9 2020, 4:28 AM

LGTM

This revision is now accepted and ready to land.Sep 9 2020, 4:28 AM
This revision was landed with ongoing or failed builds.Sep 11 2020, 7:44 PM
This revision was automatically updated to reflect the committed changes.