This is an archive of the discontinued LLVM Phabricator instance.

[PowerPC] Fix STRICT_FRINT/STRICT_FNEARBYINT lowering
ClosedPublic

Authored by qiucf on Sep 6 2020, 9:54 PM.

Details

Summary

In standard C library, both rint and nearbyint returns rounding result in current rounding mode. But nearbyint never raises inexact exception. On PowerPC, x(v|s)r(d|s)pic may modify FPSCR XX, raising inexact exception. So we can't select constrained fnearbyint into xvrdpic.

One exception here is xsrqpi, which will not raise inexact exception, so fnearbyint f128 is okay here.

Diff Detail

Event Timeline

qiucf created this revision.Sep 6 2020, 9:54 PM
Herald added a project: Restricted Project. · View Herald TranscriptSep 6 2020, 9:54 PM
qiucf requested review of this revision.Sep 6 2020, 9:54 PM
qiucf updated this revision to Diff 290181.Sep 6 2020, 10:46 PM

Fix clang to align the change

uweigand accepted this revision.Sep 8 2020, 7:01 AM

Makes sense to me. As an aside, this code:

// The nearbyint variants are not allowed to raise the inexact exception
// so we can only code-gen them with unsafe math.
if (TM.Options.UnsafeFPMath) {
  setOperationAction(ISD::FNEARBYINT, MVT::f64, Legal);
  setOperationAction(ISD::FNEARBYINT, MVT::f32, Legal);
}

is probably overly strict: FNEARBYINT (as opposed to STRICT_FNEARBYINT) is defined to ignore exceptions, whether or not we have UnsafeFPMath or not, so this can probably be enabled unconditionally.

But that can be done independently of this patch. LGTM.

This revision is now accepted and ready to land.Sep 8 2020, 7:01 AM
This revision was automatically updated to reflect the committed changes.
Herald added a project: Restricted Project. · View Herald TranscriptSep 9 2020, 7:43 AM
Herald added a subscriber: cfe-commits. · View Herald Transcript