[PATCH] D142783: [InstCombine][LV][WIP] Fold (add (zext (add X, -1)), 1) -> (zext X) if X is non-zero.

Craig Topper via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Jan 27 14:23:56 PST 2023


craig.topper created this revision.
craig.topper added reviewers: reames, nikic, fhahn, spatel.
Herald added subscribers: StephenFan, javed.absar, hiraditya.
Herald added a project: All.
craig.topper requested review of this revision.
Herald added a subscriber: pcwang-thead.
Herald added a project: LLVM.

This artifact can appear from the vectorizer. (add X, -1) is the
backedge taken count. It gets zero extended and then 1 is added to
it to get the trip count.

There is usually a dominating branch that rules out X being zero.

Alternatively, we could try to fix this in the vectorizer or the
SCEV expander maybe?


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D142783

Files:
  llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp
  llvm/test/Transforms/LoopVectorize/AArch64/intrinsiccost.ll
  llvm/test/Transforms/LoopVectorize/X86/intrinsiccost.ll
  llvm/test/Transforms/LoopVectorize/X86/small-size.ll
  llvm/test/Transforms/LoopVectorize/float-induction.ll
  llvm/test/Transforms/LoopVectorize/if-conversion-nest.ll
  llvm/test/Transforms/LoopVectorize/runtime-check.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D142783.492900.patch
Type: text/x-patch
Size: 202448 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230127/19d49263/attachment-0001.bin>


More information about the llvm-commits mailing list