diff options
author | James Molloy <james.molloy@arm.com> | 2015-08-29 10:49:11 +0000 |
---|---|---|
committer | James Molloy <james.molloy@arm.com> | 2015-08-29 10:49:11 +0000 |
commit | 45ee9898ecf58e759982be3da64d1c5599434ac3 (patch) | |
tree | 9fe878b8801a10088e4ccc0f70b437a69c67a2da /llvm/test | |
parent | c378ca50439247782a87973bf876676685297854 (diff) | |
download | bcm5719-llvm-45ee9898ecf58e759982be3da64d1c5599434ac3.tar.gz bcm5719-llvm-45ee9898ecf58e759982be3da64d1c5599434ac3.zip |
[ARM] Hoist fabs/fneg above a conversion to float.
This is especially visible in softfp mode, for example in the implementation of libm fabs/fneg functions. If we have:
%1 = vmovdrr r0, r1
%2 = fabs %1
then move the fabs before the vmovdrr:
%1 = and r1, #0x7FFFFFFF
%2 = vmovdrr r0, r1
This is never a lose, and could be a serious win because the vmovdrr may be followed by a vmovrrd, which would enable us to remove the conversion into FPRs completely.
We already do this for f32, but not for f64. Tests are added for both.
llvm-svn: 246360
Diffstat (limited to 'llvm/test')
-rw-r--r-- | llvm/test/CodeGen/ARM/softfp-fabs-fneg.ll | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/llvm/test/CodeGen/ARM/softfp-fabs-fneg.ll b/llvm/test/CodeGen/ARM/softfp-fabs-fneg.ll new file mode 100644 index 00000000000..b608fb84021 --- /dev/null +++ b/llvm/test/CodeGen/ARM/softfp-fabs-fneg.ll @@ -0,0 +1,41 @@ +; RUN: llc -mtriple=armv7 < %s | FileCheck %s --check-prefix=CHECK-ARM --check-prefix=CHECK +; RUN: llc -mtriple=thumbv7 < %s | FileCheck %s --check-prefix=CHECK-THUMB --check-prefix=CHECK + +target datalayout = "e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64" +target triple = "armv7--" + +define double @f(double %a) { + ; CHECK-LABEL: f: + ; CHECK: bfc r1, #31, #1 + ; CHECK-NEXT: bx lr + %x = call double @llvm.fabs.f64(double %a) readnone + ret double %x +} + +define float @g(float %a) { + ; CHECK-LABEL: g: + ; CHECK-THUMB: bic r0, r0, #-2147483648 + ; CHECK-ARM: bfc r0, #31, #1 + ; CHECK-NEXT: bx lr + %x = call float @llvm.fabs.f32(float %a) readnone + ret float %x +} + +define double @h(double %a) { + ; CHECK-LABEL: h: + ; CHECK: eor r1, r1, #-2147483648 + ; CHECK-NEXT: bx lr + %x = fsub nsz double -0.0, %a + ret double %x +} + +define float @i(float %a) { + ; CHECK-LABEL: i: + ; CHECK: eor r0, r0, #-2147483648 + ; CHECK-NEXT: bx lr + %x = fsub nsz float -0.0, %a + ret float %x +} + +declare double @llvm.fabs.f64(double) readnone +declare float @llvm.fabs.f32(float) readnone |