[PATCH] D35563: [DAG] Optimize away degenerate INSERT_VECTOR_ELT nodes.
Nirav Dave via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Jul 20 06:50:22 PDT 2017
This revision was automatically updated to reflect the committed changes.
Closed by commit rL308617: [DAG] Optimize away degenerate INSERT_VECTOR_ELT nodes. (authored by niravd).
Repository:
rL LLVM
https://reviews.llvm.org/D35563
Files:
llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
llvm/trunk/test/CodeGen/X86/vector-shift-ashr-256.ll
llvm/trunk/test/CodeGen/X86/vector-shift-lshr-256.ll
llvm/trunk/test/CodeGen/X86/vector-shift-shl-256.ll
llvm/trunk/test/CodeGen/X86/vector-shuffle-512-v8.ll
Index: llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
===================================================================
--- llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
+++ llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
@@ -13572,6 +13572,12 @@
EVT VT = InVec.getValueType();
+ // Remove redundant insertions:
+ // (insert_vector_elt x (extract_vector_elt x idx) idx) -> x
+ if (InVal.getOpcode() == ISD::EXTRACT_VECTOR_ELT &&
+ InVec == InVal->getOperand(0) && EltNo == InVal->getOperand(1))
+ return InVec;
+
// Check that we know which element is being inserted
if (!isa<ConstantSDNode>(EltNo))
return SDValue();
Index: llvm/trunk/test/CodeGen/X86/vector-shift-lshr-256.ll
===================================================================
--- llvm/trunk/test/CodeGen/X86/vector-shift-lshr-256.ll
+++ llvm/trunk/test/CodeGen/X86/vector-shift-lshr-256.ll
@@ -562,18 +562,14 @@
;
; X32-AVX1-LABEL: splatvar_shift_v4i64:
; X32-AVX1: # BB#0:
-; X32-AVX1-NEXT: vpextrd $1, %xmm1, %eax
-; X32-AVX1-NEXT: vpinsrd $1, %eax, %xmm1, %xmm1
; X32-AVX1-NEXT: vextractf128 $1, %ymm0, %xmm2
; X32-AVX1-NEXT: vpsrlq %xmm1, %xmm2, %xmm2
; X32-AVX1-NEXT: vpsrlq %xmm1, %xmm0, %xmm0
; X32-AVX1-NEXT: vinsertf128 $1, %xmm2, %ymm0, %ymm0
; X32-AVX1-NEXT: retl
;
; X32-AVX2-LABEL: splatvar_shift_v4i64:
; X32-AVX2: # BB#0:
-; X32-AVX2-NEXT: vpextrd $1, %xmm1, %eax
-; X32-AVX2-NEXT: vpinsrd $1, %eax, %xmm1, %xmm1
; X32-AVX2-NEXT: vpsrlq %xmm1, %ymm0, %ymm0
; X32-AVX2-NEXT: retl
%splat = shufflevector <4 x i64> %b, <4 x i64> undef, <4 x i32> zeroinitializer
Index: llvm/trunk/test/CodeGen/X86/vector-shuffle-512-v8.ll
===================================================================
--- llvm/trunk/test/CodeGen/X86/vector-shuffle-512-v8.ll
+++ llvm/trunk/test/CodeGen/X86/vector-shuffle-512-v8.ll
@@ -2735,8 +2735,6 @@
; AVX512F-32-LABEL: test_v8i64_2_5:
; AVX512F-32: # BB#0:
; AVX512F-32-NEXT: vextracti32x4 $1, %zmm0, %xmm1
-; AVX512F-32-NEXT: vpextrd $1, %xmm1, %eax
-; AVX512F-32-NEXT: vpinsrd $1, %eax, %xmm1, %xmm1
; AVX512F-32-NEXT: vextracti32x4 $2, %zmm0, %xmm0
; AVX512F-32-NEXT: vpextrd $2, %xmm0, %eax
; AVX512F-32-NEXT: vpinsrd $2, %eax, %xmm1, %xmm1
Index: llvm/trunk/test/CodeGen/X86/vector-shift-ashr-256.ll
===================================================================
--- llvm/trunk/test/CodeGen/X86/vector-shift-ashr-256.ll
+++ llvm/trunk/test/CodeGen/X86/vector-shift-ashr-256.ll
@@ -708,8 +708,6 @@
;
; X32-AVX1-LABEL: splatvar_shift_v4i64:
; X32-AVX1: # BB#0:
-; X32-AVX1-NEXT: vpextrd $1, %xmm1, %eax
-; X32-AVX1-NEXT: vpinsrd $1, %eax, %xmm1, %xmm1
; X32-AVX1-NEXT: vmovdqa {{.*#+}} xmm2 = [0,2147483648,0,2147483648]
; X32-AVX1-NEXT: vpsrlq %xmm1, %xmm2, %xmm2
; X32-AVX1-NEXT: vextractf128 $1, %ymm0, %xmm3
@@ -724,8 +722,6 @@
;
; X32-AVX2-LABEL: splatvar_shift_v4i64:
; X32-AVX2: # BB#0:
-; X32-AVX2-NEXT: vpextrd $1, %xmm1, %eax
-; X32-AVX2-NEXT: vpinsrd $1, %eax, %xmm1, %xmm1
; X32-AVX2-NEXT: vmovdqa {{.*#+}} ymm2 = [0,2147483648,0,2147483648,0,2147483648,0,2147483648]
; X32-AVX2-NEXT: vpsrlq %xmm1, %ymm2, %ymm2
; X32-AVX2-NEXT: vpsrlq %xmm1, %ymm0, %ymm0
Index: llvm/trunk/test/CodeGen/X86/vector-shift-shl-256.ll
===================================================================
--- llvm/trunk/test/CodeGen/X86/vector-shift-shl-256.ll
+++ llvm/trunk/test/CodeGen/X86/vector-shift-shl-256.ll
@@ -506,18 +506,14 @@
;
; X32-AVX1-LABEL: splatvar_shift_v4i64:
; X32-AVX1: # BB#0:
-; X32-AVX1-NEXT: vpextrd $1, %xmm1, %eax
-; X32-AVX1-NEXT: vpinsrd $1, %eax, %xmm1, %xmm1
; X32-AVX1-NEXT: vextractf128 $1, %ymm0, %xmm2
; X32-AVX1-NEXT: vpsllq %xmm1, %xmm2, %xmm2
; X32-AVX1-NEXT: vpsllq %xmm1, %xmm0, %xmm0
; X32-AVX1-NEXT: vinsertf128 $1, %xmm2, %ymm0, %ymm0
; X32-AVX1-NEXT: retl
;
; X32-AVX2-LABEL: splatvar_shift_v4i64:
; X32-AVX2: # BB#0:
-; X32-AVX2-NEXT: vpextrd $1, %xmm1, %eax
-; X32-AVX2-NEXT: vpinsrd $1, %eax, %xmm1, %xmm1
; X32-AVX2-NEXT: vpsllq %xmm1, %ymm0, %ymm0
; X32-AVX2-NEXT: retl
%splat = shufflevector <4 x i64> %b, <4 x i64> undef, <4 x i32> zeroinitializer
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D35563.107502.patch
Type: text/x-patch
Size: 4260 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170720/116adb99/attachment.bin>
More information about the llvm-commits
mailing list