[PATCH] D142847: [InstCombine] reduce icmp_eq0-of-and-of-select-of-constants

Sanjay Patel via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jan 30 11:52:04 PST 2023


spatel marked 2 inline comments as done.
spatel added a comment.

In D142847#4091133 <https://reviews.llvm.org/D142847#4091133>, @goldstein.w.n wrote:

> LGTM (although I'm not a maintainer so may want to find a bit at least for someone more familiar to checkoff).

Thanks! This has been under development in D133919 <https://reviews.llvm.org/D133919> for a while, so I feel good about it. Stamping out all of the tests for the planned enhancements is the larger effort at this point.



================
Comment at: llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp:1896
+  // TODO: Generalize for non-constant values.
+  // TODO: Invert with a "ne" predicate.
+  // TODO: Extend to handle a non-zero compare constant.
----------------
goldstein.w.n wrote:
> You could also match other predicates i.e `((x?1:4)&(y?1:4))<2`
> 
> Also it seems we already have some logic for match some other predicates in this case (although I can't find it):
> https://godbolt.org/z/hjzMGKqKz
> 
> although it seems to have an off by-1 issue (see `ugt` and `ugt3`)
>From what I see in the debug spew, some of those examples reduce via demanded bits - we shrink a select constant because some bit(s) is/are irrelevant given the compare constants. That leads to further folding via FoldOpIntoSelect or some other transform. 

But there's no general transform along these lines that I see. Ie, if we choose some other arbitrary set of constants in the tests, it may or may not fold.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D142847/new/

https://reviews.llvm.org/D142847



More information about the llvm-commits mailing list