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

Craig Topper via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Apr 9 13:04:31 PDT 2019


craig.topper created this revision.
craig.topper added reviewers: spatel, gberry, t.p.northover, RKSimon.
Herald added subscribers: hiraditya, kristof.beyls, javed.absar.
Herald added a project: LLVM.

This patch teach getTestBitOperand to look through ANY_EXTENDs when the extended bits aren't used. The test case changed here is based what D60358 <https://reviews.llvm.org/D60358> did to test16 in tbz-tbnz.ll. So this patch will avoid that regression.


https://reviews.llvm.org/D60482

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


Index: llvm/test/CodeGen/AArch64/tbz-tbnz.ll
===================================================================
--- llvm/test/CodeGen/AArch64/tbz-tbnz.ll
+++ llvm/test/CodeGen/AArch64/tbz-tbnz.ll
@@ -368,9 +368,8 @@
   %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
+; CHECK-NOT: lsl
+; CHECK: tbnz w0, #2
 
 then:
   call void @t()
Index: llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
===================================================================
--- llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
+++ llvm/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.194382.patch
Type: text/x-patch
Size: 1061 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190409/ea995fbe/attachment.bin>


More information about the llvm-commits mailing list