Skip to content
This repository was archived by the owner on Apr 23, 2020. It is now read-only.

Commit 4acf80e

Browse files
committed
[X86][MMX] Generlize MMX_MOVD64rr combines to accept v4i16/v8i8 build vectors as well as v2i32
Also handle both cases where the lower 32-bits of the MMX is undef or zero extended. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@325736 91177308-0d34-0410-b5e6-96231b3b80d8
1 parent e4507fb commit 4acf80e

File tree

2 files changed

+73
-357
lines changed

2 files changed

+73
-357
lines changed

lib/Target/X86/X86ISelLowering.cpp

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30764,13 +30764,23 @@ static SDValue combineBitcast(SDNode *N, SelectionDAG &DAG,
3076430764
DAG.getConstant(EltBits[0], DL, MVT::i32));
3076530765
}
3076630766

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+
}
3077430784
}
3077530785

3077630786
// Detect bitcasts between element or subvector extraction to x86mmx.

0 commit comments

Comments
 (0)