[PATCH] D152541: [InstCombine] Remove swapMayExposeCSEOpportunities() fold

Nikita Popov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Jun 9 07:51:21 PDT 2023


nikic created this revision.
nikic added reviewers: goldstein.w.n, RKSimon.
Herald added subscribers: StephenFan, hiraditya.
Herald added a project: All.
nikic requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

InstCombine tries to swap compare operands to match sub instructions in order to expose "CSE opportunities". However, it doesn't really make sense to perform this transform in the middle-end, as we cannot actually CSE the instructions there.

The backend already performs this fold in https://github.com/llvm/llvm-project/blob/18f5446a45da5a61dbfb1b7667d27fb441ac62db/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp#L4236 (as well as a number of more target-dependent places, e.g. optimizeCompareInstr), so I don't think we should have this in InstCombine.


https://reviews.llvm.org/D152541

Files:
  llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
  llvm/test/Transforms/InstCombine/abs-intrinsic.ll
  llvm/test/Transforms/InstCombine/icmp.ll
  llvm/test/Transforms/InstCombine/result-of-usub-is-non-zero-and-no-overflow.ll
  llvm/test/Transforms/InstCombine/strict-sub-underflow-check-to-comparison-of-sub-operands.ll
  llvm/test/Transforms/InstCombine/sub-ashr-or-to-icmp-select.ll
  llvm/test/Transforms/InstCombine/unsigned-sub-lack-of-overflow-check.ll
  llvm/test/Transforms/InstCombine/unsigned-sub-overflow-check.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D152541.529961.patch
Type: text/x-patch
Size: 12946 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230609/35ee52a6/attachment.bin>


More information about the llvm-commits mailing list