@@ -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);
0 commit comments