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 /test/CodeGen/PowerPC/rounding-ops.ll | |
parent | 5114226c1896f250be8881adf67d55a7e54b50fc (diff) | |
download | external_llvm-0882fd6c4f90f1cbaa4bb6f6ceec289428cca734.zip external_llvm-0882fd6c4f90f1cbaa4bb6f6ceec289428cca734.tar.gz external_llvm-0882fd6c4f90f1cbaa4bb6f6ceec289428cca734.tar.bz2 |
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 'test/CodeGen/PowerPC/rounding-ops.ll')
-rw-r--r-- | test/CodeGen/PowerPC/rounding-ops.ll | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/test/CodeGen/PowerPC/rounding-ops.ll b/test/CodeGen/PowerPC/rounding-ops.ll index 8177a48..b210a6b 100644 --- a/test/CodeGen/PowerPC/rounding-ops.ll +++ b/test/CodeGen/PowerPC/rounding-ops.ll @@ -106,3 +106,40 @@ define double @test10(double %x) nounwind { } declare double @trunc(double) nounwind readnone + +define float @test11(float %x) nounwind { + %call = tail call float @rintf(float %x) nounwind readnone + ret float %call + +; CHECK: test11: +; CHECK-NOT: frin + +; CHECK-FM: test11: +; CHECK-FM: frin [[R2:[0-9]+]], [[R1:[0-9]+]] +; CHECK-FM: fcmpu [[CR:[0-9]+]], [[R2]], [[R1]] +; CHECK-FM: beq [[CR]], .LBB[[BB:[0-9]+]]_2 +; CHECK-FM: mtfsb1 6 +; CHECK-FM: .LBB[[BB]]_2: +; CHECK-FM: blr +} + +declare float @rintf(float) nounwind readnone + +define double @test12(double %x) nounwind { + %call = tail call double @rint(double %x) nounwind readnone + ret double %call + +; CHECK: test12: +; CHECK-NOT: frin + +; CHECK-FM: test12: +; CHECK-FM: frin [[R2:[0-9]+]], [[R1:[0-9]+]] +; CHECK-FM: fcmpu [[CR:[0-9]+]], [[R2]], [[R1]] +; CHECK-FM: beq [[CR]], .LBB[[BB:[0-9]+]]_2 +; CHECK-FM: mtfsb1 6 +; CHECK-FM: .LBB[[BB]]_2: +; CHECK-FM: blr +} + +declare double @rint(double) nounwind readnone + |