[PATCH] D31115: [InstCombine] Provide a way to calculate KnownZero/One for Add/Sub in SimplifyDemandedUseBits without recursing into ComputeKnownBits

Craig Topper via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Mar 21 16:04:04 PDT 2017


craig.topper added inline comments.


================
Comment at: lib/Analysis/ValueTracking.cpp:309
+                                   APInt &KnownZero, APInt &KnownOne,
+                                   APInt &KnownZero2, APInt &KnownOne2,
+                                   unsigned Depth, const Query &Q) {
----------------
spatel wrote:
> Can we call these params RHSKnownZero and RHSKnownOne at this point?
They don't contain the RHS known bits at the start of the call so it could be misleading. We're only passing it in because computeKnownBits preallocated them and we want to reuse that.


================
Comment at: lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp:551
 
-    // Otherwise just hand the add/sub off to computeKnownBits to fill in
-    // the known zeros and ones.
-    computeKnownBits(V, KnownZero, KnownOne, Depth, CxtI);
+    // Otherwise commute the known bits using the RHS/LHS known bits.
+    bool NSW = cast<OverflowingBinaryOperator>(I)->hasNoSignedWrap();
----------------
spatel wrote:
> "commute" confused me here. "compute"?
> As in:
> Compute more known bits based on the existing known bits and the fact that this is an add/sub.
Typo. Maybe I've spent too much time commuting instructions in the backend.


https://reviews.llvm.org/D31115





More information about the llvm-commits mailing list