[PATCH] D53036: [InstCombine] Demand bits of UMin

Roman Lebedev via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Oct 10 04:17:59 PDT 2018


lebedev.ri accepted this revision.
lebedev.ri added a comment.
This revision is now accepted and ready to land.

Same as with https://reviews.llvm.org/D53033, looks ok, but maybe wait a bit for someone else.



================
Comment at: lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp:335-336
+      if (match(RHS, m_APInt(C)) &&
+          DemandedMask.countTrailingZeros() >=
+              C->getBitWidth() - C->countLeadingOnes())
+        return LHS;
----------------
Nit, probably ignore:
Is
```
DemandedMask.countTrailingZeros() + C->countLeadingOnes() >= C->getBitWidth()
```
worse?
I guess you could write it as 
```
DemandedMask.countTrailingZeros() >= (~C)->getActiveBits()
```
but that will be less readable, and may be worse if the compiler won't see through the bitwise-inversion.


================
Comment at: test/Transforms/InstCombine/minmax-demandbits.ll:190
 }
 
 define i8 @or_min_31_30(i8 %A) {
----------------
There are negative tests here for this fold?


https://reviews.llvm.org/D53036





More information about the llvm-commits mailing list