Skip to content

Commit 22bc9db

Browse files
authored
[SystemZ] Use the EVT version of getVectorVT() in combineTruncateExtract(). (llvm#100150)
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.
1 parent 6a1a393 commit 22bc9db

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

llvm/lib/Target/SystemZ/SystemZISelLowering.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -6653,7 +6653,8 @@ SDValue SystemZTargetLowering::combineTruncateExtract(
66536653

66546654
// Defer the creation of the bitcast from X to combineExtract,
66556655
// which might be able to optimize the extraction.
6656-
VecVT = MVT::getVectorVT(MVT::getIntegerVT(TruncBytes * 8),
6656+
VecVT = EVT::getVectorVT(*DCI.DAG.getContext(),
6657+
MVT::getIntegerVT(TruncBytes * 8),
66576658
VecVT.getStoreSize() / TruncBytes);
66586659
EVT ResVT = (TruncBytes < 4 ? MVT::i32 : TruncVT);
66596660
return combineExtract(DL, ResVT, VecVT, Vec, NewIndex, DCI, true);

llvm/test/CodeGen/SystemZ/vec-combine-01.ll

+10
Original file line numberDiff line numberDiff line change
@@ -153,3 +153,13 @@ define void @f7(ptr %ptr1, ptr %ptr2, ptr %ptr3, ptr %ptr4) {
153153
store i8 %trunc3, ptr %ptr4
154154
ret void
155155
}
156+
157+
; Test that a truncating store with a non-simple VT can be handled.
158+
define void @f8(ptr %src, ptr %dst) {
159+
; CHECK-LABEL: f8:
160+
%1 = load <12 x i32>, ptr %src, align 64
161+
%2 = extractelement <12 x i32> %1, i64 11
162+
%3 = trunc i32 %2 to i16
163+
store i16 %3, ptr %dst, align 2
164+
ret void
165+
}

0 commit comments

Comments
 (0)