[ConstProp] Don't fallthorugh for poison constants on vctp and active_lane_mask.

Given a poison constant as input, the dyn_cast to a ConstantInt would
fail so we would fall through to the generic code that attempts to fold
each element of the input vectors. The inputs to these intrinsics are
not vectors though, leading to a compile time crash. Instead bail out
properly for poison values by returning nullptr. This doesn't try to
define what poison means for these intrinsics.

Fixes #56945

GitOrigin-RevId: b2de84633a0a262b894e7cf87d29b167787aa2d6
diff --git a/lib/Analysis/ConstantFolding.cpp b/lib/Analysis/ConstantFolding.cpp
index f8d05eb..38fb503 100644
--- a/lib/Analysis/ConstantFolding.cpp
+++ b/lib/Analysis/ConstantFolding.cpp
@@ -3120,7 +3120,7 @@
       }
       return ConstantVector::get(NCs);
     }
-    break;
+    return nullptr;
   }
   case Intrinsic::get_active_lane_mask: {
     auto *Op0 = dyn_cast<ConstantInt>(Operands[0]);
@@ -3139,7 +3139,7 @@
       }
       return ConstantVector::get(NCs);
     }
-    break;
+    return nullptr;
   }
   default:
     break;
diff --git a/test/Transforms/InstSimplify/ConstProp/ARM/mve-vctp.ll b/test/Transforms/InstSimplify/ConstProp/ARM/mve-vctp.ll
index 34aea14..979fb2e 100644
--- a/test/Transforms/InstSimplify/ConstProp/ARM/mve-vctp.ll
+++ b/test/Transforms/InstSimplify/ConstProp/ARM/mve-vctp.ll
@@ -259,7 +259,14 @@
   ret <2 x i1> %int
 }
 
-
+define <4 x float> @poisonc(<4 x float> %a) {
+entry:
+  %new0 = shl i1 0, 1
+  %last = zext i1 %new0 to i32
+  %var27 = call <4 x i1> @llvm.arm.mve.vctp32(i32 %last)
+  %var33 = select <4 x i1> %var27, <4 x float> %a, <4 x float> zeroinitializer
+  ret <4 x float> %var33
+}
 
 declare <2 x i1> @llvm.arm.mve.vctp64(i32)
 declare <4 x i1> @llvm.arm.mve.vctp32(i32)
diff --git a/test/Transforms/InstSimplify/ConstProp/active-lane-mask.ll b/test/Transforms/InstSimplify/ConstProp/active-lane-mask.ll
index 7260381..4a879e8 100644
--- a/test/Transforms/InstSimplify/ConstProp/active-lane-mask.ll
+++ b/test/Transforms/InstSimplify/ConstProp/active-lane-mask.ll
@@ -292,8 +292,14 @@
 }
 
 
-
-
+define <4 x float> @poisonc(<4 x float> %a, i32 %n) {
+entry:
+  %new0 = shl i1 0, 1
+  %last = zext i1 %new0 to i32
+  %var27 = call <4 x i1> @llvm.get.active.lane.mask.v4i1.i32(i32 %last, i32 1024)
+  %var33 = select <4 x i1> %var27, <4 x float> %a, <4 x float> zeroinitializer
+  ret <4 x float> %var33
+}
 
 declare <4 x i1> @llvm.get.active.lane.mask.v4i1.i32(i32, i32)
 declare <8 x i1> @llvm.get.active.lane.mask.v8i1.i32(i32, i32)