@@ -30764,13 +30764,23 @@ static SDValue combineBitcast(SDNode *N, SelectionDAG &DAG,
30764
30764
DAG.getConstant(EltBits[0], DL, MVT::i32));
30765
30765
}
30766
30766
30767
- // Detect bitcasts between i32 to x86mmx low word.
30768
- if (N0.getOpcode() == ISD::BUILD_VECTOR && SrcVT == MVT::v2i32) {
30769
- SDValue N00 = N0.getOperand(0);
30770
- SDValue N01 = N0.getOperand(1);
30771
- if (N00.getValueType() == MVT::i32 &&
30772
- (N01.getOpcode() == ISD::UNDEF || isNullConstant(N01)))
30773
- return DAG.getNode(X86ISD::MMX_MOVW2D, SDLoc(N00), VT, N00);
30767
+ // Detect bitcasts to x86mmx low word.
30768
+ if (N0.getOpcode() == ISD::BUILD_VECTOR &&
30769
+ (SrcVT == MVT::v2i32 || SrcVT == MVT::v4i16 || SrcVT == MVT::v8i8) &&
30770
+ N0.getOperand(0).getValueType() == SrcVT.getScalarType()) {
30771
+ bool LowUndef = true, AllUndefOrZero = true;
30772
+ for (unsigned i = 1, e = SrcVT.getVectorNumElements(); i != e; ++i) {
30773
+ SDValue Op = N0.getOperand(i);
30774
+ LowUndef &= Op.isUndef() || (i >= e/2);
30775
+ AllUndefOrZero &= (Op.isUndef() || isNullConstant(Op));
30776
+ }
30777
+ if (AllUndefOrZero) {
30778
+ SDValue N00 = N0.getOperand(0);
30779
+ SDLoc dl(N00);
30780
+ N00 = LowUndef ? DAG.getAnyExtOrTrunc(N00, dl, MVT::i32)
30781
+ : DAG.getZExtOrTrunc(N00, dl, MVT::i32);
30782
+ return DAG.getNode(X86ISD::MMX_MOVW2D, dl, VT, N00);
30783
+ }
30774
30784
}
30775
30785
30776
30786
// Detect bitcasts between element or subvector extraction to x86mmx.
0 commit comments