diff --git a/llvm/lib/Target/X86/X86ISelLowering.cpp b/llvm/lib/Target/X86/X86ISelLowering.cpp index fc97c4edd0bb..8b5104f7c70b 100644 --- a/llvm/lib/Target/X86/X86ISelLowering.cpp +++ b/llvm/lib/Target/X86/X86ISelLowering.cpp @@ -3942,17 +3942,17 @@ X86TargetLowering::LowerVECTOR_SHUFFLE(SDValue Op, SelectionDAG &DAG) { else if (isIdentityMask(PermMask.getNode(), true)) return V2; + // Canonicalize movddup shuffles. + if (V2IsUndef && Subtarget->hasSSE2() && + X86::isMOVDDUPMask(PermMask.getNode())) + return CanonicalizeMovddup(Op, V1, PermMask, DAG, Subtarget->hasSSE3()); + if (isSplatMask(PermMask.getNode())) { if (isMMX || NumElems < 4) return Op; // Promote it to a v4{if}32 splat. return PromoteSplat(Op, DAG, Subtarget->hasSSE2()); } - // Canonicalize movddup shuffles. - if (V2IsUndef && Subtarget->hasSSE2() && - X86::isMOVDDUPMask(PermMask.getNode())) - return CanonicalizeMovddup(Op, V1, PermMask, DAG, Subtarget->hasSSE3()); - // If the shuffle can be profitably rewritten as a narrower shuffle, then // do it! if (VT == MVT::v8i16 || VT == MVT::v16i8) { diff --git a/llvm/test/CodeGen/X86/vec_set-9.ll b/llvm/test/CodeGen/X86/vec_set-9.ll index 38f729fbc892..5c1b8f5dacb8 100644 --- a/llvm/test/CodeGen/X86/vec_set-9.ll +++ b/llvm/test/CodeGen/X86/vec_set-9.ll @@ -1,5 +1,5 @@ ; RUN: llvm-as < %s | llc -march=x86-64 | grep movd | count 1 -; RUN: llvm-as < %s | llc -march=x86-64 | grep {punpcklqdq.*%xmm0, %xmm0} +; RUN: llvm-as < %s | llc -march=x86-64 | grep {movlhps.*%xmm0, %xmm0} define <2 x i64> @test3(i64 %A) nounwind { entry: