================
@@ -720,18 +720,17 @@ SDValue TargetLowering::SimplifyMultipleUseDemandedBits(
       unsigned Scale = NumDstEltBits / NumSrcEltBits;
       unsigned NumSrcElts = SrcVT.getVectorNumElements();
       APInt DemandedSrcBits = APInt::getZero(NumSrcEltBits);
-      APInt DemandedSrcElts = APInt::getZero(NumSrcElts);
       for (unsigned i = 0; i != Scale; ++i) {
         unsigned EltOffset = IsLE ? i : (Scale - 1 - i);
         unsigned BitOffset = EltOffset * NumSrcEltBits;
         APInt Sub = DemandedBits.extractBits(NumSrcEltBits, BitOffset);
-        if (!Sub.isZero()) {
+        if (!Sub.isZero())
           DemandedSrcBits |= Sub;
-          for (unsigned j = 0; j != NumElts; ++j)
-            if (DemandedElts[j])
-              DemandedSrcElts.setBit((j * Scale) + i);
-        }
       }
+      // Need to demand all smaller source elements that maps to a demanded
+      // destination element, since recursive calls below may turn not demanded
+      // elements into poison.
+      APInt DemandedSrcElts = APIntOps::ScaleBitMask(DemandedElts, NumSrcElts);
----------------
bjope wrote:

Checking for poison before calling Simplify* does not work as long as the 
Simply* functions are allowed to turn undemanded elements into poison.

So the idea would be that for SimplifyMultipleUseDemandedBits/VectorElts, when 
we get the new value back, then we can freeze that value instead of passing 
along the "DoNotPoison" mask as in 
https://github.com/llvm/llvm-project/pull/145903/

That was difficult to do for the normal SimplifyDemandedVectorElts that is 
doing the RAUW under the hood, but might work for the MultipleUse case.

https://github.com/llvm/llvm-project/pull/145902
_______________________________________________
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits

Reply via email to