Skip to content

Commit 92f4a2b

Browse files
RKSimontru
authored andcommitted
[x86] combineMUL - when looking for a vector multiply by splat constant, ensure we're only accepting ConstantInt splat scalars.
Fixes llvm#111170 (cherry picked from commit 9459d72)
1 parent 139d737 commit 92f4a2b

File tree

2 files changed

+35
-1
lines changed

2 files changed

+35
-1
lines changed

llvm/lib/Target/X86/X86ISelLowering.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47899,7 +47899,8 @@ static SDValue combineMul(SDNode *N, SelectionDAG &DAG,
4789947899
if (VT.isVector())
4790047900
if (auto *RawC = getTargetConstantFromNode(N->getOperand(1)))
4790147901
if (auto *SplatC = RawC->getSplatValue())
47902-
C = &(SplatC->getUniqueInteger());
47902+
if (auto *SplatCI = dyn_cast<ConstantInt>(SplatC))
47903+
C = &(SplatCI->getValue());
4790347904

4790447905
if (!C || C->getBitWidth() != VT.getScalarSizeInBits())
4790547906
return SDValue();

llvm/test/CodeGen/X86/pr111170.ll

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 5
2+
; RUN: llc < %s -mtriple=i686-pc-windows-msvc -mcpu=corei7-avx | FileCheck %s
3+
4+
define void @PR111170(<16 x i32> %x_load, ptr %offsetsPtr.i) {
5+
; CHECK-LABEL: PR111170:
6+
; CHECK: # %bb.0:
7+
; CHECK-NEXT: movl {{[0-9]+}}(%esp), %eax
8+
; CHECK-NEXT: vbroadcastss {{.*#+}} xmm2 = [2.80259693E-44,2.80259693E-44,2.80259693E-44,2.80259693E-44]
9+
; CHECK-NEXT: vpmulld %xmm2, %xmm1, %xmm3
10+
; CHECK-NEXT: vextractf128 $1, %ymm1, %xmm1
11+
; CHECK-NEXT: vpmulld %xmm2, %xmm1, %xmm1
12+
; CHECK-NEXT: vpmulld %xmm2, %xmm0, %xmm4
13+
; CHECK-NEXT: vextractf128 $1, %ymm0, %xmm0
14+
; CHECK-NEXT: vpmulld %xmm2, %xmm0, %xmm0
15+
; CHECK-NEXT: vmovdqu %xmm0, 16(%eax)
16+
; CHECK-NEXT: vmovdqu %xmm4, (%eax)
17+
; CHECK-NEXT: vmovdqu %xmm1, 48(%eax)
18+
; CHECK-NEXT: vmovdqu %xmm3, 32(%eax)
19+
; CHECK-NEXT: vpxor %xmm0, %xmm0, %xmm0
20+
; CHECK-NEXT: vmovdqu %xmm0, 16
21+
; CHECK-NEXT: vmovdqu %xmm0, 0
22+
; CHECK-NEXT: vmovdqu %xmm0, 48
23+
; CHECK-NEXT: vmovdqu %xmm0, 32
24+
; CHECK-NEXT: vzeroupper
25+
; CHECK-NEXT: retl
26+
%mul__x_load = mul <16 x i32> <i32 20, i32 20, i32 20, i32 20, i32 20, i32 20, i32 20, i32 20, i32 20, i32 20, i32 20, i32 20, i32 20, i32 20, i32 20, i32 20>, %x_load
27+
store <16 x i32> %mul__x_load, ptr %offsetsPtr.i, align 4
28+
%blend1.i12.i = call <8 x float> @llvm.x86.avx.blendv.ps.256(<8 x float> zeroinitializer, <8 x float> <float 0x36E4000000000000, float 0x36E4000000000000, float 0x36E4000000000000, float 0x36E4000000000000, float 0x36E4000000000000, float 0x36E4000000000000, float 0x36E4000000000000, float 0x36E4000000000000>, <8 x float> zeroinitializer)
29+
%blend.i13.i = shufflevector <8 x float> zeroinitializer, <8 x float> %blend1.i12.i, <16 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9, i32 10, i32 11, i32 12, i32 13, i32 14, i32 15>
30+
%blendAsInt.i14.i = bitcast <16 x float> %blend.i13.i to <16 x i32>
31+
store <16 x i32> %blendAsInt.i14.i, ptr null, align 4
32+
ret void
33+
}

0 commit comments

Comments
 (0)