xref: /llvm-project/llvm/test/Transforms/Reassociate/deadcode.ll (revision 87ae9fe415fbe729c828dbfb1491e66b11a147de)
1; RUN: opt < %s -passes=reassociate -disable-output
2
3; It has been detected that dead loops like the one in this test case can be
4; created by -passes=jump-threading (it was detected by a csmith generated program).
5;
6; According to -passes=verify this is valid input (even if it could be discussed if
7; the dead loop really satisfies SSA form).
8;
9; The problem found was that the -passes=reassociate pass ends up in an infinite loop
10; when analysing the 'deadloop1' basic block. See "Bugzilla - Bug 30818".
11define void @deadloop1() {
12  br label %endlabel
13
14deadloop1:
15  %1 = xor i32 %2, 7
16  %2 = xor i32 %1, 8
17  br label %deadloop1
18
19endlabel:
20  ret void
21}
22
23
24; Another example showing that dead code could result in infinite loops in
25; reassociate pass. See "Bugzilla - Bug 30818".
26define void @deadloop2() {
27  br label %endlabel
28
29deadloop2:
30  %1 = and i32 %2, 7
31  %2 = and i32 %3, 8
32  %3 = and i32 %1, 6
33  br label %deadloop2
34
35endlabel:
36  ret void
37}
38