[llvm] be488ba - [DAG] DAGCombiner::visitTRUNCATE - remove GetDemandedBits call

Simon Pilgrim via llvm-commits llvm-commits at lists.llvm.org
Thu Jul 28 07:25:29 PDT 2022


Author: Simon Pilgrim
Date: 2022-07-28T15:23:04+01:00
New Revision: be488ba7de2b2231101885af88c4a745ace811cf

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

LOG: [DAG] DAGCombiner::visitTRUNCATE - remove GetDemandedBits call

This should now all be handled by SimplifyDemandedBits.

Added: 
    

Modified: 
    llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
index 1bc595d11ffa..2b42a4f0df6b 100644
--- a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
@@ -13397,18 +13397,6 @@ SDValue DAGCombiner::visitTRUNCATE(SDNode *N) {
   if (SimplifyDemandedBits(SDValue(N, 0)))
     return SDValue(N, 0);
 
-  // See if we can simplify the input to this truncate through knowledge that
-  // only the low bits are being used.
-  // For example "trunc (or (shl x, 8), y)" // -> trunc y
-  // Currently we only perform this optimization on scalars because vectors
-  // may have 
diff erent active low bits.
-  if (!VT.isVector()) {
-    APInt Mask =
-        APInt::getLowBitsSet(N0.getValueSizeInBits(), VT.getSizeInBits());
-    if (SDValue Shorter = DAG.GetDemandedBits(N0, Mask))
-      return DAG.getNode(ISD::TRUNCATE, SDLoc(N), VT, Shorter);
-  }
-
   // fold (truncate (extract_subvector(ext x))) ->
   //      (extract_subvector x)
   // TODO: This can be generalized to cover cases where the truncate and extract


        


More information about the llvm-commits mailing list