[PATCH] D159327: [InstCombine] Modify all folds of `(and/or (cmp0), (cmp1))` to not quite a completed instruction; NFC

Noah Goldstein via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Aug 31 18:29:17 PDT 2023


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

In some cases it is desirable to see if a given instruction will fold,
and only if it will, create the intermediates. This is not really
possible with the current `(and/or (cmp0), (cmp1))` implementations
which only work on already built `CmpInst` values.

This has come up before (prevent folds) in cases like: D154791 <https://reviews.llvm.org/D154791>

This NFC Refactors all `(and/or (cmp0), (cmp1))` to take a new struct
`CmpComponents` instead of an `CmpInst *`. `CmpComponents` just holds
the `Predicate`, and LHS/RHS `Value` but doesn't require actually
committing to building a new instruction.  This means all the `(and/or
(cmp0), (cmp1))` folds can be checked without having to actually build
a `CmpInst`.

This patch is preperatory for a refactor of LogicalAnd/LogicalOr
handling.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D159327

Files:
  llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp
  llvm/lib/Transforms/InstCombine/InstCombineInternal.h

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D159327.555223.patch
Type: text/x-patch
Size: 39810 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230901/05ea89c1/attachment.bin>


More information about the llvm-commits mailing list