Skip to content

Commit 5ed6229

Browse files
committed
[VectorCombine] Add scalarizeLoadExtract infinite loop test from llvm#120984 regression
scalarizeLoadExtract replaces instructions up the use list, which can result in the vectorcombine worklist adding users back to the worklist when they should really be erased first.
1 parent cbff02b commit 5ed6229

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2+
; RUN: opt < %s -passes=vector-combine -S -mtriple=x86_64-- -mattr=sse2 | FileCheck %s
3+
; RUN: opt < %s -passes=vector-combine -S -mtriple=x86_64-- -mattr=avx2 | FileCheck %s
4+
5+
; infinite loop if we add the erased instructions to the work list in the wrong order.
6+
define void @multiple_extract(ptr %p) {
7+
; CHECK-LABEL: @multiple_extract(
8+
; CHECK-NEXT: [[VP:%.*]] = load ptr, ptr [[P:%.*]], align 8
9+
; CHECK-NEXT: [[TMP1:%.*]] = getelementptr inbounds <2 x i32>, ptr [[VP]], i32 0, i64 0
10+
; CHECK-NEXT: [[E0:%.*]] = load i32, ptr [[TMP1]], align 16
11+
; CHECK-NEXT: [[TMP2:%.*]] = getelementptr inbounds <2 x i32>, ptr [[VP]], i32 0, i64 1
12+
; CHECK-NEXT: [[E1:%.*]] = load i32, ptr [[TMP2]], align 4
13+
; CHECK-NEXT: store i32 [[E0]], ptr [[P]], align 4
14+
; CHECK-NEXT: [[P1:%.*]] = getelementptr inbounds nuw i8, ptr [[P]], i64 4
15+
; CHECK-NEXT: store i32 [[E1]], ptr [[P1]], align 4
16+
; CHECK-NEXT: ret void
17+
;
18+
%vp = load ptr, ptr %p, align 8
19+
%v = load <2 x i32>, ptr %vp, align 16
20+
%e0 = extractelement <2 x i32> %v, i64 0
21+
%e1 = extractelement <2 x i32> %v, i64 1
22+
store i32 %e0, ptr %p, align 4
23+
%p1 = getelementptr inbounds nuw i8, ptr %p, i64 4
24+
store i32 %e1, ptr %p1, align 4
25+
ret void
26+
}

0 commit comments

Comments
 (0)