[PATCH] D60482: [AArch64] Teach getTestBitOperand to look through ANY_EXTENDS

Phabricator via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Apr 10 10:25:52 PDT 2019


This revision was automatically updated to reflect the committed changes.
Closed by commit rL358108: [AArch64] Teach getTestBitOperand to look through ANY_EXTENDS (authored by ctopper, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D60482?vs=194382&id=194545#toc

Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D60482/new/

https://reviews.llvm.org/D60482

Files:
  llvm/trunk/lib/Target/AArch64/AArch64ISelLowering.cpp
  llvm/trunk/test/CodeGen/AArch64/tbz-tbnz.ll


Index: llvm/trunk/test/CodeGen/AArch64/tbz-tbnz.ll
===================================================================
--- llvm/trunk/test/CodeGen/AArch64/tbz-tbnz.ll
+++ llvm/trunk/test/CodeGen/AArch64/tbz-tbnz.ll
@@ -360,17 +360,22 @@
   ret void
 }
 
-define void @test20(i32 %in) {
-; CHECK-LABEL: @test20
+define void @test20(i32 %in) nounwind {
+; CHECK-LABEL: test20:
+; CHECK:       // %bb.0:
+; CHECK-NEXT:    tbnz w0, #2, .LBB19_2
+; CHECK-NEXT:  // %bb.1: // %then
+; CHECK-NEXT:    str x30, [sp, #-16]! // 8-byte Folded Spill
+; CHECK-NEXT:    bl t
+; CHECK-NEXT:    ldr x30, [sp], #16 // 8-byte Folded Reload
+; CHECK-NEXT:  .LBB19_2: // %end
+; CHECK-NEXT:    ret
   %shl = shl i32 %in, 3
   %zext = zext i32 %shl to i64
   %and = and i64 %zext, 32
   %cond = icmp eq i64 %and, 0
   br i1 %cond, label %then, label %end
 
-; FIXME: Should be no lsl
-; CHECK: lsl w8, w0, #3
-; CHECK: tbnz w8, #5
 
 then:
   call void @t()
Index: llvm/trunk/lib/Target/AArch64/AArch64ISelLowering.cpp
===================================================================
--- llvm/trunk/lib/Target/AArch64/AArch64ISelLowering.cpp
+++ llvm/trunk/lib/Target/AArch64/AArch64ISelLowering.cpp
@@ -11038,6 +11038,12 @@
     return getTestBitOperand(Op->getOperand(0), Bit, Invert, DAG);
   }
 
+  // (tbz (any_ext x), b) -> (tbz x, b) if we don't use the extended bits.
+  if (Op->getOpcode() == ISD::ANY_EXTEND &&
+      Bit < Op->getOperand(0).getValueSizeInBits()) {
+    return getTestBitOperand(Op->getOperand(0), Bit, Invert, DAG);
+  }
+
   if (Op->getNumOperands() != 2)
     return Op;
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D60482.194545.patch
Type: text/x-patch
Size: 1585 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190410/333c7539/attachment.bin>


More information about the llvm-commits mailing list