diff options
author | James Molloy <james.molloy@arm.com> | 2015-11-10 14:22:05 +0000 |
---|---|---|
committer | James Molloy <james.molloy@arm.com> | 2015-11-10 14:22:05 +0000 |
commit | 9d55f19cfa69fbd4a85d5207a4e30c67cec9df89 (patch) | |
tree | 3f0c91378a33e99ae9e8651f58fa0b88bc591222 /llvm/test/CodeGen | |
parent | c78e89962a64879a6967e4434c4e64747b3d3e4b (diff) | |
download | bcm5719-llvm-9d55f19cfa69fbd4a85d5207a4e30c67cec9df89.tar.gz bcm5719-llvm-9d55f19cfa69fbd4a85d5207a4e30c67cec9df89.zip |
Reapply "[ARM] Combine CMOV into BFI where possible"
Added fixes for stage2 failures: CMOV is not commutable; commuting the operands results in the condition being flipped! d'oh!
Original commit message:
If we have a CMOV, OR and AND combination such as:
if (x & CN)
y |= CM;
And:
* CN is a single bit;
* All bits covered by CM are known zero in y;
Then we can convert this to a sequence of BFI instructions. This will always be a win if CM is a single bit, will always be no worse than the TST & OR sequence if CM is two bits, and for thumb will be no worse if CM is three bits (due to the extra IT instruction).
llvm-svn: 252606
Diffstat (limited to 'llvm/test/CodeGen')
-rw-r--r-- | llvm/test/CodeGen/ARM/bfi.ll | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/llvm/test/CodeGen/ARM/bfi.ll b/llvm/test/CodeGen/ARM/bfi.ll index 0661960d1ae..0707838e9ef 100644 --- a/llvm/test/CodeGen/ARM/bfi.ll +++ b/llvm/test/CodeGen/ARM/bfi.ll @@ -74,3 +74,37 @@ entry: %or = or i32 %shl, %and ret i32 %or } + +define i32 @f7(i32 %x, i32 %y) { +; CHECK-LABEL: f7: +; CHECK: bfi r1, r0, #4, #1 + %y2 = and i32 %y, 4294967040 ; 0xFFFFFF00 + %and = and i32 %x, 4 + %or = or i32 %y2, 16 + %cmp = icmp ne i32 %and, 0 + %sel = select i1 %cmp, i32 %or, i32 %y2 + ret i32 %sel +} + +define i32 @f8(i32 %x, i32 %y) { +; CHECK-LABEL: f8: +; CHECK: bfi r1, r0, #4, #1 +; CHECK: bfi r1, r0, #5, #1 + %y2 = and i32 %y, 4294967040 ; 0xFFFFFF00 + %and = and i32 %x, 4 + %or = or i32 %y2, 48 + %cmp = icmp ne i32 %and, 0 + %sel = select i1 %cmp, i32 %or, i32 %y2 + ret i32 %sel +} + +define i32 @f9(i32 %x, i32 %y) { +; CHECK-LABEL: f9: +; CHECK-NOT: bfi + %y2 = and i32 %y, 4294967040 ; 0xFFFFFF00 + %and = and i32 %x, 4 + %or = or i32 %y2, 48 + %cmp = icmp ne i32 %and, 0 + %sel = select i1 %cmp, i32 %y2, i32 %or + ret i32 %sel +} |