[PATCH] D135847: [PowerPC] don't check CTR clobber in hardware loop insertion pass

ChenZheng via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Nov 7 23:17:22 PST 2022


shchenz added inline comments.


================
Comment at: llvm/test/CodeGen/PowerPC/pr36292.ll:22
+; CHECK-NEXT:    .p2align 4
+; CHECK-NEXT:  .LBB0_1: # %forcond
+; CHECK-NEXT:    #
----------------
lkail wrote:
> Do you have any idea of this regression? Looks we have additional `addi` and `b` in the loop after the change.
Now in the hardware insertion pass, we treat this loop as an hardware loop without checking the loop body. So the hardware insertion pass will try to calculate the loop count in the loop preheader and then decrease the loop count in the loop latch. This is different with the left one. The left one is not a CTR loop form, i.e. the loop count is not calculated in the loop preheader.

This adds more instructions(`addi` and `bc`, please note that the last branch is changed to uncontional branch) in the loop body. but for other case, if the body has no CTR clobber, it is a valid CTR loop which can benefit other optimizations.


================
Comment at: llvm/test/CodeGen/PowerPC/pr55463.ll:71
 ; CHECK-NEXT:    evmergelo 3, 3, 4
-; CHECK-NEXT:    addi 28, 28, 1
+; CHECK-NEXT:    addi 28, 28, -1
 ; CHECK-NEXT:    cmplwi 28, 0
----------------
lkail wrote:
> nit: `undef` leads to flag flip.
Can you be more specific? Do you mean we should not use `addi -1`? The `addi -1` is hard-coded. See https://github.com/llvm/llvm-project/blob/main/llvm/lib/Target/PowerPC/PPCCTRLoops.cpp#L263-L266 .


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D135847



More information about the llvm-commits mailing list