[PATCH] D126591: [InstCombine] Optimise shift+and+boolean conversion pattern to simple comparison

chenglin.bi via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jun 20 05:12:08 PDT 2022


bcl5980 added a comment.

In D126591#3596021 <https://reviews.llvm.org/D126591#3596021>, @spatel wrote:

> I added a similar fold here:
> 0399473de886 <https://reviews.llvm.org/rG0399473de886595d8ce3346f2cc99c94267496e5>
>
> It seems like we might be missing some generalization for power-of-2 values, but this patch seems fine. Please add alive2 links to the patch summary (these are in issue #56124?).

alive2 link should already in the summary.



================
Comment at: llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp:5568-5569
+        if (C1->isOne() && C2.isPowerOf2()) {
           // ((1 << X) & 8) == 0 -> X != 3
           // ((1 << X) & 8) != 0 -> X == 3
+          auto *CmpC = ConstantInt::get(XTy, C2.countTrailingZeros());
----------------
spatel wrote:
> Is this just a special-case of the next pattern? If so, I think it is better to reduce the patch. We might have slightly less efficiency at run-time, but there's less code to maintain here.
I think it is not. But we can remove that after rGbfde861.
And we can also remove line 5590's transform after rGa0c3c607.
Do we need to remvoe these on this patch?


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

https://reviews.llvm.org/D126591



More information about the llvm-commits mailing list