[llvm] fd90f54 - [InstCombine] improve efficiency of sub demanded bits; NFC

Sanjay Patel via llvm-commits llvm-commits at lists.llvm.org
Thu Oct 27 12:37:30 PDT 2022


Author: Sanjay Patel
Date: 2022-10-27T15:28:05-04:00
New Revision: fd90f542cf60c2a4e735f35513268c052686dbd6

URL: https://github.com/llvm/llvm-project/commit/fd90f542cf60c2a4e735f35513268c052686dbd6
DIFF: https://github.com/llvm/llvm-project/commit/fd90f542cf60c2a4e735f35513268c052686dbd6.diff

LOG: [InstCombine] improve efficiency of sub demanded bits; NFC

There's no reason to shrink a constant or simplify
an operand in 2 steps.

This matches what we currently do for 'add' (although that
seems like it should be altered to handle the commutative
case).

Added: 
    

Modified: 
    llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp b/llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp
index 25b005b31dd88..6fdafbf2bb367 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp
@@ -545,9 +545,6 @@ Value *InstCombinerImpl::SimplifyDemandedUseBits(Value *V, APInt DemandedMask,
     if (ShrinkDemandedConstant(I, 1, DemandedFromOps) ||
         SimplifyDemandedBits(I, 1, DemandedFromOps, RHSKnown, Depth + 1))
       return disableWrapFlagsBasedOnUnusedHighBits(I, NLZ);
-    if (ShrinkDemandedConstant(I, 0, DemandedFromOps) ||
-        SimplifyDemandedBits(I, 0, DemandedFromOps, LHSKnown, Depth + 1))
-      return disableWrapFlagsBasedOnUnusedHighBits(I, NLZ);
 
     // If low order bits are not demanded and are known to be zero in RHS,
     // then we don't need to demand them from LHS, since they can't cause a
@@ -557,7 +554,7 @@ Value *InstCombinerImpl::SimplifyDemandedUseBits(Value *V, APInt DemandedMask,
     DemandedFromLHS.clearLowBits(NTZ);
     if (ShrinkDemandedConstant(I, 0, DemandedFromLHS) ||
         SimplifyDemandedBits(I, 0, DemandedFromLHS, LHSKnown, Depth + 1))
-      return I;
+      return disableWrapFlagsBasedOnUnusedHighBits(I, NLZ);
 
     // If we are known to be subtracting zeros from every bit below
     // the highest demanded bit, we just return the other side.


        


More information about the llvm-commits mailing list