diff options
author | Hal Finkel <hfinkel@anl.gov> | 2013-03-29 19:41:55 +0000 |
---|---|---|
committer | Hal Finkel <hfinkel@anl.gov> | 2013-03-29 19:41:55 +0000 |
commit | 0882fd6c4f90f1cbaa4bb6f6ceec289428cca734 (patch) | |
tree | 53a0c59a3544690e09572552450574f32786f3af /lib/Target/PowerPC/PPCInstrInfo.td | |
parent | 5114226c1896f250be8881adf67d55a7e54b50fc (diff) |
Implement FRINT lowering on PPC using frin
Like nearbyint, rint can be implemented on PPC using the frin instruction. The
complication comes from the fact that rint needs to set the FE_INEXACT flag
when the result does not equal the input value (and frin does not do that). As
a result, we use a custom inserter which, after the rounding, compares the
rounded value with the original, and if they differ, explicitly sets the XX bit
in the FPSCR register (which corresponds to FE_INEXACT).
Once LLVM has better modeling of the floating-point environment we should be
able to (often) eliminate this extra complexity.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@178362 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Target/PowerPC/PPCInstrInfo.td')
-rw-r--r-- | lib/Target/PowerPC/PPCInstrInfo.td | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/lib/Target/PowerPC/PPCInstrInfo.td b/lib/Target/PowerPC/PPCInstrInfo.td index af3b57f2ed..f897a47800 100644 --- a/lib/Target/PowerPC/PPCInstrInfo.td +++ b/lib/Target/PowerPC/PPCInstrInfo.td @@ -1141,6 +1141,15 @@ let Uses = [RM] in { "frin $frD, $frB", FPGeneral, [(set f32:$frD, (fnearbyint f32:$frB))]>; + // These pseudos expand to rint but also set FE_INEXACT when the result does + // not equal the argument. + let usesCustomInserter = 1, Defs = [RM] in { // FIXME: Model FPSCR! + def FRINDrint : Pseudo<(outs F8RC:$frD), (ins F8RC:$frB), + "#FRINDrint", [(set f64:$frD, (frint f64:$frB))]>; + def FRINSrint : Pseudo<(outs F4RC:$frD), (ins F4RC:$frB), + "#FRINSrint", [(set f32:$frD, (frint f32:$frB))]>; + } + def FRIPD : XForm_26<63, 456, (outs F8RC:$frD), (ins F8RC:$frB), "frip $frD, $frB", FPGeneral, [(set f64:$frD, (fceil f64:$frB))]>; |