[llvm] [InstCombine] Simplify demanded bits of blendv mask operands (PR #173723)

Dhruva Narayan K via llvm-commits llvm-commits at lists.llvm.org
Sat Dec 27 08:03:51 PST 2025


================
@@ -2870,11 +2870,31 @@ X86TTIImpl::instCombineIntrinsic(InstCombiner &IC, IntrinsicInst &II) const {
   case Intrinsic::x86_avx_blendv_ps_256:
   case Intrinsic::x86_avx_blendv_pd_256:
   case Intrinsic::x86_avx2_pblendvb: {
+
+    Value *Mask = II.getArgOperand(2);
+
+    unsigned BitWidth = Mask->getType()->getScalarSizeInBits();
+    KnownBits Known(BitWidth);
+
+    if (Mask->getType()->isIntOrIntVectorTy()) {
+      if (IC.SimplifyDemandedBits(&II, 2, APInt::getSignMask(BitWidth), Known))
+        return ⅈ
+    }
+
+    else if (auto *BC = dyn_cast<BitCastInst>(Mask)) {
+      Value *Src = BC->getOperand(0);
+      if (Src->getType()->isIntOrIntVectorTy()) {
----------------
Xylecrack wrote:

i have updated the patch

https://github.com/llvm/llvm-project/pull/173723


More information about the llvm-commits mailing list