[PATCH] D151799: [ConstraintElim] Try to use first cmp to prove second cmp for ANDs.

Florian Hahn via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed May 31 06:24:30 PDT 2023


fhahn created this revision.
fhahn added reviewers: nikic, zjaffal, mkazantsev, rapidsna.
Herald added subscribers: StephenFan, hiraditya.
Herald added a project: All.
fhahn requested review of this revision.
Herald added a project: LLVM.

This patch extends the existing logic to handle cases where we have
branch conditions of the form (AND icmp, icmp) where the first icmp
implies the second. This can improve results in some cases, e.g. if
SimplifyCFG folded conditions from multiple branches to an AND.

The implementation handles this by adding a new type of check
(AndImpliedCheck), which are queued before conditional facts for the same
block.

When encountering AndImpliedChecks during solving, the first condition
is optimistically added to the constraint system, then we check if the
second icmp can be simplified, and finally the newly added entries are
removed.

The reason for doing things this way is to avoid clashes with signed
<-> unsigned condition transfer, which require us to re-order facts to
increase effectiveness.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D151799

Files:
  llvm/lib/Transforms/Scalar/ConstraintElimination.cpp
  llvm/test/Transforms/ConstraintElimination/and-implied-by-operands.ll
  llvm/test/Transforms/ConstraintElimination/gep-arithmetic-signed-predicates.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D151799.527009.patch
Type: text/x-patch
Size: 7622 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230531/2855b428/attachment.bin>


More information about the llvm-commits mailing list