OSDN Git Service

Implement FRINT lowering on PPC using frin
authorHal Finkel <hfinkel@anl.gov>
Fri, 29 Mar 2013 19:41:55 +0000 (19:41 +0000)
committerHal Finkel <hfinkel@anl.gov>
Fri, 29 Mar 2013 19:41:55 +0000 (19:41 +0000)
commit0882fd6c4f90f1cbaa4bb6f6ceec289428cca734
tree53a0c59a3544690e09572552450574f32786f3af
parent5114226c1896f250be8881adf67d55a7e54b50fc
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
lib/Target/PowerPC/PPCISelLowering.cpp
lib/Target/PowerPC/PPCInstrInfo.td
test/CodeGen/PowerPC/rounding-ops.ll