[PATCH] D134954: [InstCombine] Switch foldOpIntoPhi() to use InstSimplify

Nikita Popov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Sep 30 05:46:55 PDT 2022


nikic created this revision.
nikic added a reviewer: spatel.
Herald added a subscriber: hiraditya.
Herald added a project: All.
nikic requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

foldOpIntoPhi() currently only folds operations into the phi if all but one operands constant-fold. The two exceptions to this are freeze and select, where we allow more general simplification.

This patch makes foldOpIntoPhi() generally simplification based and removes all the instruction-specific logic. We just try to simplify the instruction for each operand, and for the (potentially) one non-simplified operand, we move it into the new block with adjusted operands.

This fixes https://github.com/llvm/llvm-project/issues/57448, which was my original motivation for the change.

There is some measurable compile-time impact (http://llvm-compile-time-tracker.com/compare.php?from=215c9fa4deac9ec6b4e504843830551f03b60620&to=af3f96e67cdcbb736d8f13d35769bab5091dc403&stat=instructions), but it is in the 0.05% range, so I think this is fine.


https://reviews.llvm.org/D134954

Files:
  llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
  llvm/test/Transforms/InstCombine/intptr1.ll
  llvm/test/Transforms/InstCombine/intptr4.ll
  llvm/test/Transforms/InstCombine/intptr5.ll
  llvm/test/Transforms/InstCombine/intptr7.ll
  llvm/test/Transforms/InstCombine/phi-select-constant.ll
  llvm/test/Transforms/InstCombine/phi.ll
  llvm/test/Transforms/InstCombine/recurrence.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D134954.464236.patch
Type: text/x-patch
Size: 21394 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220930/33215822/attachment.bin>


More information about the llvm-commits mailing list