[llvm-branch-commits] [llvm] 0adb0f9 - [ConstProp] Don't fallthorugh for poison constants on vctp and active_lane_mask.

Tom Stellard via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Mon Aug 8 12:22:55 PDT 2022


Author: David Green
Date: 2022-08-08T12:22:10-07:00
New Revision: 0adb0f9a97c7cd6e6d315d533b4db452456ebe13

URL: https://github.com/llvm/llvm-project/commit/0adb0f9a97c7cd6e6d315d533b4db452456ebe13
DIFF: https://github.com/llvm/llvm-project/commit/0adb0f9a97c7cd6e6d315d533b4db452456ebe13.diff

LOG: [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

(cherry picked from commit b2de84633a0a262b894e7cf87d29b167787aa2d6)

Added: 
    

Modified: 
    llvm/lib/Analysis/ConstantFolding.cpp
    llvm/test/Transforms/InstSimplify/ConstProp/ARM/mve-vctp.ll
    llvm/test/Transforms/InstSimplify/ConstProp/active-lane-mask.ll

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Analysis/ConstantFolding.cpp b/llvm/lib/Analysis/ConstantFolding.cpp
index aa4da27be4e57..ae927dae74f7d 100644
--- a/llvm/lib/Analysis/ConstantFolding.cpp
+++ b/llvm/lib/Analysis/ConstantFolding.cpp
@@ -3120,7 +3120,7 @@ static Constant *ConstantFoldFixedVectorCall(
       }
       return ConstantVector::get(NCs);
     }
-    break;
+    return nullptr;
   }
   case Intrinsic::get_active_lane_mask: {
     auto *Op0 = dyn_cast<ConstantInt>(Operands[0]);
@@ -3139,7 +3139,7 @@ static Constant *ConstantFoldFixedVectorCall(
       }
       return ConstantVector::get(NCs);
     }
-    break;
+    return nullptr;
   }
   default:
     break;

diff  --git a/llvm/test/Transforms/InstSimplify/ConstProp/ARM/mve-vctp.ll b/llvm/test/Transforms/InstSimplify/ConstProp/ARM/mve-vctp.ll
index 34aea14b594c5..979fb2e84ba92 100644
--- a/llvm/test/Transforms/InstSimplify/ConstProp/ARM/mve-vctp.ll
+++ b/llvm/test/Transforms/InstSimplify/ConstProp/ARM/mve-vctp.ll
@@ -259,7 +259,14 @@ entry:
   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/llvm/test/Transforms/InstSimplify/ConstProp/active-lane-mask.ll b/llvm/test/Transforms/InstSimplify/ConstProp/active-lane-mask.ll
index 7260381222896..4a879e837f835 100644
--- a/llvm/test/Transforms/InstSimplify/ConstProp/active-lane-mask.ll
+++ b/llvm/test/Transforms/InstSimplify/ConstProp/active-lane-mask.ll
@@ -292,8 +292,14 @@ entry:
 }
 
 
-
-
+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)


        


More information about the llvm-branch-commits mailing list