[PATCH] D17942: [AArch64] Optimize test and branch sequence when the test's constant operand is power of 2

Tim Northover via llvm-commits llvm-commits at lists.llvm.org
Tue Mar 8 09:57:45 PST 2016


t.p.northover added inline comments.

================
Comment at: lib/Target/AArch64/AArch64InstrInfo.cpp:3016
@@ +3015,3 @@
+  // Look for AND if MI is CBZ/CBNZ and DefMI is a COPY instruction
+  if (!IsTestAndBranch && DefMI->isCopy()) {
+    if (DefMI->getParent() != MBB) return false;
----------------
This looks overly specialized to me: "look through precisely one COPY, but don't accept a direct AND".

Shouldn't we make the look-through-copy logic generic (so it applies to the CSINC/CBZ too), and iterative?

================
Comment at: lib/Target/AArch64/AArch64InstrInfo.cpp:3073
@@ -3006,3 +3072,3 @@
   // Look for CSINC
   if (!(DefMI->getOpcode() == AArch64::CSINCWr &&
         DefMI->getOperand(1).getReg() == AArch64::WZR &&
----------------
I'd be inclined to make this whole thing a switch on `DefMI->getOpcode()` once it's been found. They're handled more like sibling cases anyway, and I could easily see us adding other patterns later.


http://reviews.llvm.org/D17942





More information about the llvm-commits mailing list