Skip to content

Commit e1d2251

Browse files
committed
[SLP]Fix minbitwidth analysis for gather nodes with icmp users.
If the node is not in MinBWs container and the user node is icmp node, the compiler should not check the type size of the user instruction, it is always 1 and is not good for actual bitwidth analysis. Fixes llvm#105988
1 parent 4b0c0ec commit e1d2251

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15975,6 +15975,10 @@ void BoUpSLP::computeMinimumValueSizes() {
1597515975
auto It = MinBWs.find(TE);
1597615976
if (It != MinBWs.end() && It->second.first > UserTESz)
1597715977
return true;
15978+
// The size of icmp is always 1 and should not be
15979+
// considered.
15980+
if (TE->getOpcode() == Instruction::ICmp)
15981+
return true;
1597815982
return DL->getTypeSizeInBits(U->getType()) > UserTESz;
1597915983
}));
1598015984
})) {

llvm/test/Transforms/SLPVectorizer/X86/gather-with-cmp-user.ll

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,13 @@ define i1 @test(i32 %g, i16 %d) {
77
; CHECK-NEXT: [[ENTRY:.*:]]
88
; CHECK-NEXT: [[TMP0:%.*]] = and i16 [[D]], 1
99
; CHECK-NEXT: [[XOR_I_I:%.*]] = xor i32 [[G]], 1
10-
; CHECK-NEXT: [[TMP1:%.*]] = trunc i32 [[G]] to i8
11-
; CHECK-NEXT: [[TMP2:%.*]] = insertelement <2 x i8> poison, i8 [[TMP1]], i32 0
12-
; CHECK-NEXT: [[TMP3:%.*]] = trunc i32 [[XOR_I_I]] to i8
13-
; CHECK-NEXT: [[TMP4:%.*]] = insertelement <2 x i8> [[TMP2]], i8 [[TMP3]], i32 1
10+
; CHECK-NEXT: [[TMP1:%.*]] = insertelement <2 x i32> poison, i32 [[G]], i32 0
11+
; CHECK-NEXT: [[TMP9:%.*]] = insertelement <2 x i32> [[TMP1]], i32 [[XOR_I_I]], i32 1
12+
; CHECK-NEXT: [[TMP4:%.*]] = trunc <2 x i32> [[TMP9]] to <2 x i8>
1413
; CHECK-NEXT: [[TMP5:%.*]] = shufflevector <2 x i8> [[TMP4]], <2 x i8> poison, <4 x i32> <i32 0, i32 1, i32 0, i32 1>
1514
; CHECK-NEXT: [[TMP6:%.*]] = add <4 x i8> [[TMP5]], <i8 -9, i8 -9, i8 -1, i8 -1>
1615
; CHECK-NEXT: [[TMP7:%.*]] = icmp sgt <4 x i8> [[TMP6]], <i8 -3, i8 -3, i8 -3, i8 -3>
1716
; CHECK-NEXT: [[TMP8:%.*]] = zext <4 x i1> [[TMP7]] to <4 x i8>
18-
; CHECK-NEXT: [[TMP9:%.*]] = sext <2 x i8> [[TMP4]] to <2 x i32>
1917
; CHECK-NEXT: [[TMP10:%.*]] = shufflevector <2 x i32> [[TMP9]], <2 x i32> poison, <4 x i32> <i32 0, i32 1, i32 0, i32 1>
2018
; CHECK-NEXT: [[TMP11:%.*]] = zext <4 x i8> [[TMP8]] to <4 x i32>
2119
; CHECK-NEXT: [[TMP12:%.*]] = icmp sgt <4 x i32> [[TMP10]], [[TMP11]]

0 commit comments

Comments
 (0)