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

Sanjay Patel via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jun 22 05:20:33 PDT 2022


spatel added inline comments.


================
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());
----------------
bcl5980 wrote:
> 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?
Yes, I prefer to remove code if we have other transforms to handle the patterns now. We do not want to keep dead code around - it makes the compiler slower and harder to understand.


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

https://reviews.llvm.org/D126591



More information about the llvm-commits mailing list