diff options
author | Tim Northover <tnorthover@apple.com> | 2016-04-15 18:17:18 +0000 |
---|---|---|
committer | Tim Northover <tnorthover@apple.com> | 2016-04-15 18:17:18 +0000 |
commit | 903f81ba184d45341f8f5b8b3227242cc168e535 (patch) | |
tree | ce9f92d8728653aa3e465e394d818795897899b0 /llvm/test | |
parent | 9cfd8cea6b8172e32a76a59125f13a6662a18c86 (diff) | |
download | bcm5719-llvm-903f81ba184d45341f8f5b8b3227242cc168e535.tar.gz bcm5719-llvm-903f81ba184d45341f8f5b8b3227242cc168e535.zip |
ARM: don't try to hoist constant RHS out of a division.
Divisions by a constant can be converted into multiplies which are usually
cheaper, but this isn't possible if the constant gets separated (particularly
in loops). Fix this by telling ConstantHoisting that the immediate in a DIV is
cheap.
I considered making the check generic, but neither AArch64 (strangely) nor x86
showed any benefit on the tests I had.
llvm-svn: 266464
Diffstat (limited to 'llvm/test')
-rw-r--r-- | llvm/test/Transforms/ConstantHoisting/ARM/bad-cases.ll | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/llvm/test/Transforms/ConstantHoisting/ARM/bad-cases.ll b/llvm/test/Transforms/ConstantHoisting/ARM/bad-cases.ll index 3602eb9f3fd..8fa78e3d69b 100644 --- a/llvm/test/Transforms/ConstantHoisting/ARM/bad-cases.ll +++ b/llvm/test/Transforms/ConstantHoisting/ARM/bad-cases.ll @@ -45,3 +45,48 @@ bb2: default: ret void } + +; We don't want to convert constant divides because the benefit from converting +; them to a mul in the backend is larget than constant materialization savings. +define void @signed_const_division(i32 %in1, i32 %in2, i32* %addr) { +; CHECK-LABEL: @signed_const_division +; CHECK: %res1 = sdiv i32 %l1, 1000000000 +; CHECK: %res2 = srem i32 %l2, 1000000000 +entry: + br label %loop + +loop: + %l1 = phi i32 [%res1, %loop], [%in1, %entry] + %l2 = phi i32 [%res2, %loop], [%in2, %entry] + %res1 = sdiv i32 %l1, 1000000000 + store volatile i32 %res1, i32* %addr + %res2 = srem i32 %l2, 1000000000 + store volatile i32 %res2, i32* %addr + %again = icmp eq i32 %res1, %res2 + br i1 %again, label %loop, label %end + +end: + ret void +} + +define void @unsigned_const_division(i32 %in1, i32 %in2, i32* %addr) { +; CHECK-LABEL: @unsigned_const_division +; CHECK: %res1 = udiv i32 %l1, 1000000000 +; CHECK: %res2 = urem i32 %l2, 1000000000 + +entry: + br label %loop + +loop: + %l1 = phi i32 [%res1, %loop], [%in1, %entry] + %l2 = phi i32 [%res2, %loop], [%in2, %entry] + %res1 = udiv i32 %l1, 1000000000 + store volatile i32 %res1, i32* %addr + %res2 = urem i32 %l2, 1000000000 + store volatile i32 %res2, i32* %addr + %again = icmp eq i32 %res1, %res2 + br i1 %again, label %loop, label %end + +end: + ret void +} |