[DAGCombine] visitTRUNCATE - remove GetDemandedBits call
authorSimon Pilgrim <llvm-dev@redking.me.uk>
Sat, 2 May 2020 18:51:58 +0000 (19:51 +0100)
committerSimon Pilgrim <llvm-dev@redking.me.uk>
Sat, 2 May 2020 18:52:17 +0000 (19:52 +0100)
rL368553 added SimplifyMultipleUseDemandedBits handling for ISD::TRUNCATE to SimplifyDemandedBits so we don't need to duplicate this (and it gets rid of another GetDemandedBits call which is slowly being replaced with SimplifyMultipleUseDemandedBits anyhow).

llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp

index d8c6b51..3c8d1f3 100644 (file)
@@ -11112,18 +11112,6 @@ SDValue DAGCombiner::visitTRUNCATE(SDNode *N) {
     }
   }
 
-  // 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 different 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 (load x)) -> (smaller load x)
   // fold (truncate (srl (load x), c)) -> (smaller load (x+c/evtbits))
   if (!LegalTypes || TLI.isTypeDesirableForOp(N0.getOpcode(), VT)) {