[llvm] 858d6a1 - [wasm] Don't crash on non-simple value types during shuffle combine

Benjamin Kramer via llvm-commits llvm-commits at lists.llvm.org
Tue Oct 24 03:36:18 PDT 2023


Author: Benjamin Kramer
Date: 2023-10-24T12:35:43+02:00
New Revision: 858d6a15a0baea233c032e5048968f1cfbbed876

URL: https://github.com/llvm/llvm-project/commit/858d6a15a0baea233c032e5048968f1cfbbed876
DIFF: https://github.com/llvm/llvm-project/commit/858d6a15a0baea233c032e5048968f1cfbbed876.diff

LOG: [wasm] Don't crash on non-simple value types during shuffle combine

These still exist during the DAGCombine phase.

Added: 
    

Modified: 
    llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp
    llvm/test/CodeGen/WebAssembly/simd-shuffle-bitcast.ll

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp b/llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp
index 70629b2a50a982a..4bcf89690505edd 100644
--- a/llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp
+++ b/llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp
@@ -2472,8 +2472,8 @@ performVECTOR_SHUFFLECombine(SDNode *N, TargetLowering::DAGCombinerInfo &DCI) {
   if (!N->getOperand(1).isUndef())
     return SDValue();
   SDValue CastOp = Bitcast.getOperand(0);
-  MVT SrcType = CastOp.getSimpleValueType();
-  MVT DstType = Bitcast.getSimpleValueType();
+  EVT SrcType = CastOp.getValueType();
+  EVT DstType = Bitcast.getValueType();
   if (!SrcType.is128BitVector() ||
       SrcType.getVectorNumElements() != DstType.getVectorNumElements())
     return SDValue();

diff  --git a/llvm/test/CodeGen/WebAssembly/simd-shuffle-bitcast.ll b/llvm/test/CodeGen/WebAssembly/simd-shuffle-bitcast.ll
index 2aebae5231f4b9a..1f539f16520045f 100644
--- a/llvm/test/CodeGen/WebAssembly/simd-shuffle-bitcast.ll
+++ b/llvm/test/CodeGen/WebAssembly/simd-shuffle-bitcast.ll
@@ -16,6 +16,15 @@ define <4 x i32> @f32x4_splat(float %x) {
   ret <4 x i32> %b
 }
 
+; CHECK-LABEL: i2x2_splat:
+; CHECK-NEXT: .functype i2x2_splat (i32) -> (v128){{$}}
+define <2 x i2> @i2x2_splat(i1 %x) {
+  %vecinit = insertelement <4 x i1> undef, i1 %x, i32 0
+  %a = bitcast <4 x i1> %vecinit to <2 x i2>
+  %b = shufflevector <2 x i2> %a, <2 x i2> undef, <2 x i32> zeroinitializer
+  ret <2 x i2> %b
+}
+
 ; CHECK-LABEL: not_a_vec:
 ; CHECK-NEXT: .functype not_a_vec (i64, i64) -> (v128){{$}}
 ; CHECK-NEXT: i32.wrap_i64    $push[[L:[0-9]+]]=, $0


        


More information about the llvm-commits mailing list