Skip to content

Commit 25dd67e

Browse files
committed
[X86][AVX] foldShuffleOfHorizOp - don't attempt to handle 256-bit X86ISD::VBROADCAST (PR49971)
NOTE: This is for the 12.x release branch ONLY Minimal patch to avoid the issue encountered in PR49971 (it's already been dealt with in trunk through a larger refactor that can't be easily merged). Bail for non-128-bit vector broadcasts of (F)HADD/SUB ops - the existing logic doesn't correctly deal with the fact that the broadcast will splat across the 128-bit lanes. Reviewed By: spatel, wristow Differential Revision: https://reviews.llvm.org/D101104
1 parent 072c90a commit 25dd67e

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

llvm/lib/Target/X86/X86ISelLowering.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37889,6 +37889,8 @@ static SDValue foldShuffleOfHorizOp(SDNode *N, SelectionDAG &DAG) {
3788937889
// replicating low and high halves (and without changing the type/length of
3789037890
// the vector), we don't need the shuffle.
3789137891
if (Opcode == X86ISD::MOVDDUP || Opcode == X86ISD::VBROADCAST) {
37892+
if (Opcode == X86ISD::VBROADCAST && !VT.is128BitVector())
37893+
return SDValue();
3789237894
if (HOp.getScalarValueSizeInBits() == 64 && HOp.getValueType() == VT) {
3789337895
// movddup (hadd X, X) --> hadd X, X
3789437896
// broadcast (extract_vec_elt (hadd X, X), 0) --> hadd X, X

llvm/test/CodeGen/X86/horizontal-shuffle-3.ll

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,17 @@ define <8 x i32> @test_unpackhi_hsub_v8i32(<8 x i32> %0, <8 x i32> %1, <8 x i32>
9898
ret <8 x i32> %7
9999
}
100100

101+
define <4 x double> @PR49971(<4 x double> %0) {
102+
; CHECK-LABEL: PR49971:
103+
; CHECK: ## %bb.0:
104+
; CHECK-NEXT: vhaddpd %xmm0, %xmm0, %xmm0
105+
; CHECK-NEXT: vbroadcastsd %xmm0, %ymm0
106+
; CHECK-NEXT: ret{{[l|q]}}
107+
%2 = tail call <4 x double> @llvm.x86.avx.hadd.pd.256(<4 x double> %0, <4 x double> %0)
108+
%3 = shufflevector <4 x double> %2, <4 x double> undef, <4 x i32> <i32 0, i32 1, i32 0, i32 1>
109+
ret <4 x double> %3
110+
}
111+
101112
declare <8 x float> @llvm.x86.avx.hadd.ps.256(<8 x float>, <8 x float>)
102113
declare <8 x float> @llvm.x86.avx.hsub.ps.256(<8 x float>, <8 x float>)
103114
declare <4 x double> @llvm.x86.avx.hadd.pd.256(<4 x double>, <4 x double>)

0 commit comments

Comments
 (0)