[SystemZ] Use the EVT version of getVectorVT() in combineTruncateExtract(). (#100150)
authorJonas Paulsson <paulson1@linux.ibm.com>
Fri, 26 Jul 2024 12:33:40 +0000 (14:33 +0200)
committerTobias Hieta <tobias@hieta.se>
Mon, 18 Nov 2024 16:02:29 +0000 (17:02 +0100)
A test case showed up where the new vector type is v24i16, which is not a simple
MVT. In order to get an extended value type for cases like this, EVT::getVectorVT()
needs to be called instead of MVT::getVectorVT(), otherwise the following call
to getVectorElementType() in combineExtract() will fail.

(cherry picked from commit 22bc9db92b46965882b1c77aebc86430149b0912)

llvm/lib/Target/SystemZ/SystemZISelLowering.cpp
llvm/test/CodeGen/SystemZ/vec-combine-01.ll

index b2b88143354a59d6fcfdc839656205b0a14ae59c..383393914a1695b97d6f01b27f927f0effdb1970 100644 (file)
@@ -6653,7 +6653,8 @@ SDValue SystemZTargetLowering::combineTruncateExtract(
 
           // Defer the creation of the bitcast from X to combineExtract,
           // which might be able to optimize the extraction.
-          VecVT = MVT::getVectorVT(MVT::getIntegerVT(TruncBytes * 8),
+          VecVT = EVT::getVectorVT(*DCI.DAG.getContext(),
+                                   MVT::getIntegerVT(TruncBytes * 8),
                                    VecVT.getStoreSize() / TruncBytes);
           EVT ResVT = (TruncBytes < 4 ? MVT::i32 : TruncVT);
           return combineExtract(DL, ResVT, VecVT, Vec, NewIndex, DCI, true);
index 6f0abd6ea5bafe20ae18676cbf5851a71d821dbc..16231b2d895264eb770bd935c877dec8df5d6323 100644 (file)
@@ -153,3 +153,13 @@ define void @f7(ptr %ptr1, ptr %ptr2, ptr %ptr3, ptr %ptr4) {
   store i8 %trunc3, ptr %ptr4
   ret void
 }
+
+; Test that a truncating store with a non-simple VT can be handled.
+define void @f8(ptr %src, ptr %dst) {
+; CHECK-LABEL: f8:
+  %1 = load <12 x i32>, ptr %src, align 64
+  %2 = extractelement <12 x i32> %1, i64 11
+  %3 = trunc i32 %2 to i16
+  store i16 %3, ptr %dst, align 2
+  ret void
+}