Skip to content

Commit 3fc0b9a

Browse files
committed
address comments
1 parent 3186a56 commit 3fc0b9a

File tree

2 files changed

+17
-14
lines changed

2 files changed

+17
-14
lines changed

llvm/lib/Target/PowerPC/PPCISelLowering.cpp

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9667,18 +9667,17 @@ SDValue PPCTargetLowering::LowerBUILD_VECTOR(SDValue Op,
96679667
bool IsSplat64 = false;
96689668
uint64_t SplatBits = 0;
96699669
int32_t SextVal = 0;
9670-
if (BVNIsConstantSplat) {
9670+
if (BVNIsConstantSplat && SplatBitSize <= 64) {
9671+
SplatBits = APSplatBits.getZExtValue();
96719672
if (SplatBitSize <= 32) {
9672-
SplatBits = APSplatBits.getZExtValue();
96739673
SextVal = SignExtend32(SplatBits, SplatBitSize);
96749674
} else if (SplatBitSize == 64 && Subtarget.hasP8Altivec()) {
9675-
int64_t Splat64Val = APSplatBits.getSExtValue();
9676-
SplatBits = (uint64_t)Splat64Val;
9677-
SextVal = (int32_t)SplatBits;
9675+
int64_t Splat64Val = static_cast<int64_t>(SplatBits);
96789676
bool P9Vector = Subtarget.hasP9Vector();
96799677
int32_t Hi = P9Vector ? 127 : 15;
96809678
int32_t Lo = P9Vector ? -128 : -16;
96819679
IsSplat64 = Splat64Val >= Lo && Splat64Val <= Hi;
9680+
SextVal = static_cast<int32_t>(SplatBits);
96829681
}
96839682
}
96849683

@@ -9818,15 +9817,19 @@ SDValue PPCTargetLowering::LowerBUILD_VECTOR(SDValue Op,
98189817
SDValue C = DAG.getConstant((unsigned char)SextVal, dl, MVT::i32);
98199818
SmallVector<SDValue, 16> Ops(16, C);
98209819
SDValue BV = DAG.getBuildVector(MVT::v16i8, dl, Ops);
9821-
assert((SplatSize == 2 || SplatSize == 4 || SplatSize == 8) &&
9822-
"Unexpected type for vector constant.");
98239820
unsigned IID;
9824-
if (SplatSize == 2) {
9821+
switch (SplatSize) {
9822+
default:
9823+
llvm_unreachable("Unexpected type for vector constant.");
9824+
case 2:
98259825
IID = Intrinsic::ppc_altivec_vupklsb;
9826-
} else if (SplatSize == 4) {
9826+
break;
9827+
case 4:
98279828
IID = Intrinsic::ppc_altivec_vextsb2w;
9828-
} else { // SplatSize == 8
9829+
break;
9830+
case 8:
98299831
IID = Intrinsic::ppc_altivec_vextsb2d;
9832+
break;
98309833
}
98319834
SDValue Extend = BuildIntrinsicOp(IID, BV, DAG, dl);
98329835
return DAG.getBitcast(Op->getValueType(0), Extend);

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
; RUN: -mcpu=pwr9 -ppc-asm-full-reg-names -ppc-vsr-nums-as-vr < %s | \
1010
; RUN: FileCheck %s
1111

12-
define dso_local noundef <8 x i16> @v103s() local_unnamed_addr #0 {
12+
define dso_local noundef <8 x i16> @v103s() local_unnamed_addr {
1313
; CHECK-LABEL: v103s:
1414
; CHECK: # %bb.0: # %entry
1515
; CHECK-NEXT: xxspltib v2, 103
@@ -19,7 +19,7 @@ entry:
1919
ret <8 x i16> splat (i16 103)
2020
}
2121

22-
define dso_local noundef <2 x i64> @v103l() local_unnamed_addr #0 {
22+
define dso_local noundef <2 x i64> @v103l() local_unnamed_addr {
2323
; CHECK-LABEL: v103l:
2424
; CHECK: # %bb.0: # %entry
2525
; CHECK-NEXT: xxspltib v2, 103
@@ -29,7 +29,7 @@ entry:
2929
ret <2 x i64> splat (i64 103)
3030
}
3131

32-
define dso_local noundef <4 x i32> @v103i() local_unnamed_addr #0 {
32+
define dso_local noundef <4 x i32> @v103i() local_unnamed_addr {
3333
; CHECK-LABEL: v103i:
3434
; CHECK: # %bb.0: # %entry
3535
; CHECK-NEXT: xxspltib v2, 103
@@ -39,7 +39,7 @@ entry:
3939
ret <4 x i32> splat (i32 103)
4040
}
4141

42-
define dso_local noundef <2 x i64> @v11l() local_unnamed_addr #0 {
42+
define dso_local noundef <2 x i64> @v11l() local_unnamed_addr {
4343
; CHECK-LABEL: v11l:
4444
; CHECK: # %bb.0: # %entry
4545
; CHECK-NEXT: vspltisw v2, -11

0 commit comments

Comments
 (0)