summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp5
-rw-r--r--llvm/test/CodeGen/X86/vector-idiv.ll8
2 files changed, 10 insertions, 3 deletions
diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp b/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
index 3f68d49da68..46d0fcac410 100644
--- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
@@ -1441,6 +1441,11 @@ SDValue SelectionDAG::getVectorShuffle(EVT VT, SDLoc dl, SDValue N1,
if (Identity && NElts)
return N1;
+ // Shuffling a constant splat doesn't change the result.
+ if (N2Undef && N1.getOpcode() == ISD::BUILD_VECTOR)
+ if (cast<BuildVectorSDNode>(N1)->getConstantSplatValue())
+ return N1;
+
FoldingSetNodeID ID;
SDValue Ops[2] = { N1, N2 };
AddNodeIDNode(ID, ISD::VECTOR_SHUFFLE, getVTList(VT), Ops, 2);
diff --git a/llvm/test/CodeGen/X86/vector-idiv.ll b/llvm/test/CodeGen/X86/vector-idiv.ll
index 3b300f74061..981c317157f 100644
--- a/llvm/test/CodeGen/X86/vector-idiv.ll
+++ b/llvm/test/CodeGen/X86/vector-idiv.ll
@@ -115,6 +115,7 @@ define <4 x i32> @test8(<4 x i32> %a) {
; SSE-LABEL: test8:
; SSE: pmuldq
; SSE: pshufd $57
+; SSE-NOT: pshufd $57
; SSE: pmuldq
; SSE: shufps $-35
; SSE: pshufd $-40
@@ -126,6 +127,7 @@ define <4 x i32> @test8(<4 x i32> %a) {
; AVX-LABEL: test8:
; AVX: vpmuldq
; AVX: vpshufd $57
+; AVX-NOT: vpshufd $57
; AVX: vpmuldq
; AVX: vshufps $-35
; AVX: vpshufd $-40
@@ -140,7 +142,7 @@ define <8 x i32> @test9(<8 x i32> %a) {
ret <8 x i32> %div
; AVX-LABEL: test9:
-; AVX: vpermd
+; AVX: vpbroadcastd
; AVX: vpmuldq
; AVX: vshufps $-35
; AVX: vpmuldq
@@ -157,7 +159,7 @@ define <8 x i32> @test10(<8 x i32> %a) {
ret <8 x i32> %rem
; AVX-LABEL: test10:
-; AVX: vpermd
+; AVX: vpbroadcastd
; AVX: vpmuludq
; AVX: vshufps $-35
; AVX: vpmuludq
@@ -174,7 +176,7 @@ define <8 x i32> @test11(<8 x i32> %a) {
ret <8 x i32> %rem
; AVX-LABEL: test11:
-; AVX: vpermd
+; AVX: vpbroadcastd
; AVX: vpmuldq
; AVX: vshufps $-35
; AVX: vpmuldq
OpenPOWER on IntegriCloud