Skip to content

Commit 1eb575d

Browse files
authored
[PowerPC] Fix vector extend result types in BUILD_VECTOR lowering (#159398)
The result type of the vector extend intrinsics generated by the BUILD_VECTOR lowering code should match how they are actually defined. Currently the result type is defaulting to the operand type there. This can conflict with calls to the same intrinsic from other paths.
1 parent ac8f3cd commit 1eb575d

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

llvm/lib/Target/PowerPC/PPCISelLowering.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9904,20 +9904,24 @@ SDValue PPCTargetLowering::LowerBUILD_VECTOR(SDValue Op,
99049904
SmallVector<SDValue, 16> Ops(16, C);
99059905
SDValue BV = DAG.getBuildVector(MVT::v16i8, dl, Ops);
99069906
unsigned IID;
9907+
EVT VT;
99079908
switch (SplatSize) {
99089909
default:
99099910
llvm_unreachable("Unexpected type for vector constant.");
99109911
case 2:
99119912
IID = Intrinsic::ppc_altivec_vupklsb;
9913+
VT = MVT::v8i16;
99129914
break;
99139915
case 4:
99149916
IID = Intrinsic::ppc_altivec_vextsb2w;
9917+
VT = MVT::v4i32;
99159918
break;
99169919
case 8:
99179920
IID = Intrinsic::ppc_altivec_vextsb2d;
9921+
VT = MVT::v2i64;
99189922
break;
99199923
}
9920-
SDValue Extend = BuildIntrinsicOp(IID, BV, DAG, dl);
9924+
SDValue Extend = BuildIntrinsicOp(IID, BV, DAG, dl, VT);
99219925
return DAG.getBitcast(Op->getValueType(0), Extend);
99229926
}
99239927
assert(!IsSplat64 && "Unhandled 64-bit splat pattern");

llvm/test/CodeGen/PowerPC/splat-extend.ll

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,3 +48,21 @@ define dso_local noundef <2 x i64> @v11l() local_unnamed_addr {
4848
entry:
4949
ret <2 x i64> splat (i64 -11)
5050
}
51+
52+
declare <4 x i32> @llvm.ppc.altivec.vextsb2w(<16 x i8>)
53+
54+
define i32 @crash(ptr %p) {
55+
; CHECK-LABEL: crash:
56+
; CHECK: # %bb.0: # %entry
57+
; CHECK-NEXT: xxspltib v2, 127
58+
; CHECK-NEXT: vextsb2w v2, v2
59+
; CHECK-NEXT: stxv v2, 0(r3)
60+
; CHECK-NEXT: li r3, 0
61+
; CHECK-NEXT: stxv v2, 0(0)
62+
; CHECK-NEXT: blr
63+
entry:
64+
store <4 x i32> <i32 127, i32 127, i32 127, i32 127>, ptr %p, align 16
65+
%0 = call <4 x i32> @llvm.ppc.altivec.vextsb2w(<16 x i8> <i8 127, i8 127, i8 127, i8 127, i8 127, i8 127, i8 127, i8 127, i8 127, i8 127, i8 127, i8 127, i8 127, i8 127, i8 127, i8 127>)
66+
store <4 x i32> %0, ptr null, align 16
67+
ret i32 0
68+
}

0 commit comments

Comments
 (0)