[PATCH] D18572: [AArch64] Relax branches by fusing compare with conditional branch when we can infer that source register is zero/non-zero.

Tim Northover via llvm-commits llvm-commits at lists.llvm.org
Thu Mar 31 10:35:57 PDT 2016


t.p.northover added a comment.

> Second, this is a type of branch relaxation optimization because the branch displacement of cbz is better than a conditional branch IMHO.


What gave you that idea? They both seem to allow imm19*4.


================
Comment at: lib/Target/AArch64/AArch64BranchRelaxation.cpp:483
@@ +482,3 @@
+  if (!Compare->getOperand(1).isReg() || !Compare->getOperand(2).isImm() ||
+      Compare->getOperand(2).getImm() != 1)
+    return false;
----------------
bmakam wrote:
> t.p.northover wrote:
> > What about "cmp reg, #0"/"b.le ..."?
> This could be turned into a TBNZ but isn't AArch64ConditionOptimizer a better place to handle this? Although this is very similar we only fuse a compare with branch in this patch i.e.  (a>0 && a<1) -> a == 0 or (a>0 && a>= 1) -> a != 0 and so it depends on branchfolding to shape the CFG.
The case I'm talking about is analogous though: "a > 0 && a <= 0 -> a != 0".


http://reviews.llvm.org/D18572





More information about the llvm-commits mailing list