Skip to content

Commit a001008

Browse files
committed
[X86] combineExtractWithShuffle - more aggressively peek through bitcasts
Fixes regression introduced by rL352743 llvm-svn: 352745
1 parent 4fda072 commit a001008

File tree

2 files changed

+22
-33
lines changed

2 files changed

+22
-33
lines changed

llvm/lib/Target/X86/X86ISelLowering.cpp

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33861,15 +33861,19 @@ static SDValue combineExtractWithShuffle(SDNode *N, SelectionDAG &DAG,
3386133861
if (SrcSVT == MVT::i1 || !isa<ConstantSDNode>(Idx))
3386233862
return SDValue();
3386333863

33864+
SDValue SrcBC = peekThroughBitcasts(Src);
33865+
3386433866
// Handle extract(broadcast(scalar_value)), it doesn't matter what index is.
33865-
if (X86ISD::VBROADCAST == Src.getOpcode() &&
33866-
Src.getOperand(0).getValueType() == VT)
33867-
return Src.getOperand(0);
33867+
if (X86ISD::VBROADCAST == SrcBC.getOpcode()) {
33868+
SDValue SrcOp = SrcBC.getOperand(0);
33869+
if (SrcOp.getValueSizeInBits() == VT.getSizeInBits())
33870+
return DAG.getBitcast(VT, SrcOp);
33871+
}
3386833872

3386933873
// Resolve the target shuffle inputs and mask.
3387033874
SmallVector<int, 16> Mask;
3387133875
SmallVector<SDValue, 2> Ops;
33872-
if (!resolveTargetShuffleInputs(peekThroughBitcasts(Src), Ops, Mask, DAG))
33876+
if (!resolveTargetShuffleInputs(SrcBC, Ops, Mask, DAG))
3387333877
return SDValue();
3387433878

3387533879
// Attempt to narrow/widen the shuffle mask to the correct size.

llvm/test/CodeGen/X86/extractelement-load.ll

Lines changed: 14 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2-
; RUN: llc < %s -mtriple=i686-unknown -mattr=+sse2 | FileCheck %s --check-prefix=X32-SSE2
3-
; RUN: llc < %s -mtriple=x86_64-unknown -mattr=+ssse3 | FileCheck %s --check-prefix=X64-SSSE3
4-
; RUN: llc < %s -mtriple=x86_64-unknown -mattr=+avx | FileCheck %s --check-prefix=X64-AVX
2+
; RUN: llc < %s -mtriple=i686-unknown -mattr=+sse2 | FileCheck %s --check-prefixes=X32-SSE2
3+
; RUN: llc < %s -mtriple=x86_64-unknown -mattr=+ssse3 | FileCheck %s --check-prefixes=X64,X64-SSSE3
4+
; RUN: llc < %s -mtriple=x86_64-unknown -mattr=+avx | FileCheck %s --check-prefixes=X64,X64-AVX
55

66
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
77

@@ -12,15 +12,10 @@ define i32 @t(<2 x i64>* %val) nounwind {
1212
; X32-SSE2-NEXT: movl 8(%eax), %eax
1313
; X32-SSE2-NEXT: retl
1414
;
15-
; X64-SSSE3-LABEL: t:
16-
; X64-SSSE3: # %bb.0:
17-
; X64-SSSE3-NEXT: movl 8(%rdi), %eax
18-
; X64-SSSE3-NEXT: retq
19-
;
20-
; X64-AVX-LABEL: t:
21-
; X64-AVX: # %bb.0:
22-
; X64-AVX-NEXT: movl 8(%rdi), %eax
23-
; X64-AVX-NEXT: retq
15+
; X64-LABEL: t:
16+
; X64: # %bb.0:
17+
; X64-NEXT: movl 8(%rdi), %eax
18+
; X64-NEXT: retq
2419
%tmp2 = load <2 x i64>, <2 x i64>* %val, align 16 ; <<2 x i64>> [#uses=1]
2520
%tmp3 = bitcast <2 x i64> %tmp2 to <4 x i32> ; <<4 x i32>> [#uses=1]
2621
%tmp4 = extractelement <4 x i32> %tmp3, i32 2 ; <i32> [#uses=1]
@@ -34,13 +29,9 @@ define i32 @t2(<8 x i32>* %xp) {
3429
; X32-SSE2: # %bb.0:
3530
; X32-SSE2-NEXT: retl
3631
;
37-
; X64-SSSE3-LABEL: t2:
38-
; X64-SSSE3: # %bb.0:
39-
; X64-SSSE3-NEXT: retq
40-
;
41-
; X64-AVX-LABEL: t2:
42-
; X64-AVX: # %bb.0:
43-
; X64-AVX-NEXT: retq
32+
; X64-LABEL: t2:
33+
; X64: # %bb.0:
34+
; X64-NEXT: retq
4435
%x = load <8 x i32>, <8 x i32>* %xp
4536
%Shuff68 = shufflevector <8 x i32> %x, <8 x i32> undef, <8 x i32> <i32 undef, i32 7, i32 9, i32 undef, i32 13, i32 15, i32 1, i32 3>
4637
%y = extractelement <8 x i32> %Shuff68, i32 0
@@ -91,16 +82,10 @@ define i64 @t4(<2 x double>* %a) {
9182
; X32-SSE2-NEXT: movd %xmm0, %edx
9283
; X32-SSE2-NEXT: retl
9384
;
94-
; X64-SSSE3-LABEL: t4:
95-
; X64-SSSE3: # %bb.0:
96-
; X64-SSSE3-NEXT: movq (%rdi), %rax
97-
; X64-SSSE3-NEXT: retq
98-
;
99-
; X64-AVX-LABEL: t4:
100-
; X64-AVX: # %bb.0:
101-
; X64-AVX-NEXT: vmovddup {{.*#+}} xmm0 = mem[0,0]
102-
; X64-AVX-NEXT: vpextrq $1, %xmm0, %rax
103-
; X64-AVX-NEXT: retq
85+
; X64-LABEL: t4:
86+
; X64: # %bb.0:
87+
; X64-NEXT: movq (%rdi), %rax
88+
; X64-NEXT: retq
10489
%b = load <2 x double>, <2 x double>* %a, align 16
10590
%c = shufflevector <2 x double> %b, <2 x double> %b, <2 x i32> <i32 1, i32 0>
10691
%d = bitcast <2 x double> %c to <2 x i64>

0 commit comments

Comments
 (0)