[PATCH] D63477: [PowerPC] exclude ICmpZero Use in LSR in that icmp can be replaced inside hardware loop.

ChenZheng via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jun 18 01:31:06 PDT 2019


shchenz created this revision.
shchenz added reviewers: hfinkel, jsji, nemanjai, stefanp, steven.zhang.
Herald added subscribers: asbirlea, kbarton, hiraditya, javed.absar.
Herald added a project: LLVM.

Currently pass LSR runs before PPCCTRLoops, we meet some problem with this order because of the icmp inside loop which compares iteration indexed and loop count. In pass LSR, we always treat that icmp as a valid ICmpZero type LSRUse. But this is not true because in later pass HardwareLoops pass, we may replace this icmp with ctrloop instruction mtctr/bdnz. So we may get suboptimal code based on this order.

In Patch https://reviews.llvm.org/D62847, I made a patch which reorders LSR Pass and HardwareLoops pass. By reordering, LSR knows precisely whether the icmp is replaced or kept in HardwareLoops pass. But reviewers is uneasy about that patch and suggests we should add a target hook in LSR.

This patch add a target hook `canSaveCmp()` in `TTI`, it returns true only when we are sure that current handling loop in LSR is a hardware loop.

This patch includes a NFC patch which will be reviewed in a seperated patch.


https://reviews.llvm.org/D63477

Files:
  llvm/include/llvm/Analysis/TargetTransformInfo.h
  llvm/include/llvm/Analysis/TargetTransformInfoImpl.h
  llvm/include/llvm/CodeGen/BasicTTIImpl.h
  llvm/lib/Analysis/TargetTransformInfo.cpp
  llvm/lib/CodeGen/HardwareLoops.cpp
  llvm/lib/Target/ARM/ARMTargetTransformInfo.cpp
  llvm/lib/Target/ARM/ARMTargetTransformInfo.h
  llvm/lib/Target/PowerPC/PPCTargetTransformInfo.cpp
  llvm/lib/Target/PowerPC/PPCTargetTransformInfo.h
  llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
  llvm/test/CodeGen/PowerPC/addi-licm.ll
  llvm/test/CodeGen/PowerPC/ctrloop-ne.ll
  llvm/test/CodeGen/PowerPC/ctrloop-shortLoops.ll
  llvm/test/CodeGen/PowerPC/lsr-ctrloop.ll
  llvm/test/CodeGen/PowerPC/negctr.ll
  llvm/test/CodeGen/PowerPC/stwu-sched.ll
  llvm/test/CodeGen/PowerPC/unal-altivec.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D63477.205268.patch
Type: text/x-patch
Size: 32269 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190618/38ed220b/attachment.bin>


More information about the llvm-commits mailing list