This is an archive of the discontinued LLVM Phabricator instance.

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

Authored by goldstein.w.n on Aug 31 2023, 6:29 PM.

Details

Reviewers
nikic
RKSimon
Summary

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

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.

Diff Detail