[PATCH] D156401: [PatternMatch] Do not match constant expressions for binops

Nikita Popov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jul 27 01:26:08 PDT 2023


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

Currently, m_Mul style matchers also match constant expressions. This is a regular source of assertion failures (usually by trying to do a match and then cast to Instruction or BinaryOperator) and infinite combine loops. At the same time, I don't think this provides useful optimization capabilities (all of the tests affected here are regression tests for crashes / infinite loops).

Long term, all of these constant expressions (apart from add/sub possibly) are slated for removal per https://discourse.llvm.org/t/rfc-remove-most-constant-expressions/63179 -- but doing those removals can itself expose new crashed and infinite loops due to the current PatternMatch behavior. I've been working on removing and expressions, and I've already run into 3 issues of that kind.


https://reviews.llvm.org/D156401

Files:
  llvm/include/llvm/IR/PatternMatch.h
  llvm/test/Transforms/InstCombine/mul-inseltpoison.ll
  llvm/test/Transforms/InstCombine/mul.ll
  llvm/test/Transforms/InstCombine/pr32686.ll
  llvm/test/Transforms/InstCombine/switch-constant-expr.ll
  llvm/test/Transforms/InstCombine/udiv-simplify.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D156401.544647.patch
Type: text/x-patch
Size: 6176 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230727/3dc550b9/attachment.bin>


More information about the llvm-commits mailing list