[llvm] [ConstantFolding] Fold scalable get_active_lane_masks (PR #156659)

David Green via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 4 03:16:04 PDT 2025


================
@@ -4238,6 +4238,13 @@ static Constant *ConstantFoldScalableVectorCall(
 
     return ConstantInt::getFalse(SVTy);
   }
+  case Intrinsic::get_active_lane_mask: {
+    auto Op0 = cast<ConstantInt>(Operands[0])->getValue();
+    auto Op1 = cast<ConstantInt>(Operands[1])->getValue();
+    if ((Op0.uge(Op1) && (!Op1.isZero())))
----------------
davemgreen wrote:

Yep, poison propagates so if it is not frozen it can have different values at different places.
https://llvm.org/docs/LangRef.html#poison-values
Producing all-ones would be valid (if it was poison), but not as useful.

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


More information about the llvm-commits mailing list