Skip to content

Commit

Permalink
[ARM] Allow CMPZ transforms even if the input has multiple uses.
Browse files Browse the repository at this point in the history
It looks like this got left in by accident in r289794; I can't think of
any reason this check would be necessary.  (Maybe it was meant to be a
check that the AND has one use? But we check that a few lines earlier.)

Differential Revision: https://reviews.llvm.org/D47921

llvm-svn: 334322
  • Loading branch information
Eli Friedman committed Jun 8, 2018
1 parent 79510be commit 864df22
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 4 deletions.
2 changes: 1 addition & 1 deletion llvm/lib/Target/ARM/ARMISelDAGToDAG.cpp
Expand Up @@ -2459,7 +2459,7 @@ void ARMDAGToDAGISel::SelectCMPZ(SDNode *N, bool &SwitchEQNEToPLMI) {
SDValue X = And.getOperand(0);
auto C = dyn_cast<ConstantSDNode>(And.getOperand(1));

if (!C || !X->hasOneUse())
if (!C)
return;
auto Range = getContiguousRangeOfSetBits(C->getAPIntValue());
if (!Range)
Expand Down
18 changes: 18 additions & 0 deletions llvm/test/CodeGen/ARM/and-cmpz.ll
Expand Up @@ -18,6 +18,24 @@ false:
ret i32 2
}

; CHECK-LABEL: single_bit_multi_use:
; CHECK: lsls r0, r0, #23
; T2-NEXT: mov
; T2-NEXT: it
; T1-NEXT: bmi
define i32 @single_bit_multi_use(i32 %p, i32* %z) {
store i32 %p, i32* %z
%a = and i32 %p, 256
%b = icmp eq i32 %a, 0
br i1 %b, label %true, label %false

true:
ret i32 1

false:
ret i32 2
}

; CHECK-LABEL: multi_bit_lsb_ubfx:
; CHECK: lsls r0, r0, #24
; T2-NEXT: mov
Expand Down
2 changes: 1 addition & 1 deletion llvm/test/CodeGen/ARM/load_i1_select.ll
Expand Up @@ -8,7 +8,7 @@ target triple = "thumbv7-apple-ios0.0.0"

; CHECK-LABEL: foo:
; CHECK: ldrb r[[R0:[0-9]+]], [r0]
; CHECK: tst.w r[[R0]], #1
; CHECK: lsls r{{[0-9]+}}, r[[R0]], #31
define void @foo(i8* %call, double* %p) nounwind {
entry:
%tmp2 = load i8, i8* %call
Expand Down
4 changes: 2 additions & 2 deletions llvm/test/CodeGen/Thumb/thumb-shrink-wrapping.ll
Expand Up @@ -646,12 +646,12 @@ define i1 @beq_to_bx(i32* %y, i32 %head) {
; CHECK-NEXT: beq [[EXIT_LABEL:LBB[0-9_]+]]
; ENABLE: push {r4, lr}

; CHECK: tst r3, r4
; CHECK: lsls r4, r3, #30
; ENABLE-NEXT: ldr [[POP:r[4567]]], [sp, #4]
; ENABLE-NEXT: mov lr, [[POP]]
; ENABLE-NEXT: pop {[[POP]]}
; ENABLE-NEXT: add sp, #4
; CHECK-NEXT: beq [[EXIT_LABEL]]
; CHECK-NEXT: bpl [[EXIT_LABEL]]

; CHECK: str r1, [r2]
; CHECK: str r3, [r2]
Expand Down

0 comments on commit 864df22

Please sign in to comment.