xref: /llvm-project/llvm/test/tools/llvm-diff/assumption-report-order.ll (revision e044796132abd9e10e21093822dc234003628fbd)
1; Check that differences are reported in the BB processing order
2; following the control flow, independent on whether the diff was depending
3; on an assumption or not.
4;
5; Replace %newvar1 with %newvar2 in the phi node. This can only
6; be detected to be different once BB2 has been processed, so leads to a assumption
7; and is detected to diff later on.
8; Also, replace the 1000 by 2000 in BB1, which is detected directly.
9;
10; RUN: rm -f %t.ll
11; RUN: cat %s | sed -e 's/ %newvar1, %BB2 / %newvar2, %BB2 /' | sed -e 's/1000/2000/' > %t.ll
12; RUN: not llvm-diff %s %t.ll 2>&1 | FileCheck %s
13
14; CHECK:      in function func:
15; CHECK-NEXT:   in block %BB0:
16; CHECK-NEXT:     >   %var = phi i32 [ 0, %ENTRY ], [ %newvar2, %BB2 ]
17; CHECK-NEXT:     <   %var = phi i32 [ 0, %ENTRY ], [ %newvar1, %BB2 ]
18; CHECK-NEXT:   in block %BB1:
19; CHECK-NEXT:     >   %diffvar = add i32 %var, 2000
20; CHECK-NEXT:     <   %diffvar = add i32 %var, 1000
21
22define i32 @func() {
23ENTRY:
24  br label %BB0
25
26BB0:
27  ; When diffing this phi node, we need to detect whether
28  ; %newvar1 is equivalent, which is not known until BB2 has been processed.
29  %var = phi i32 [ 0, %ENTRY ], [ %newvar1, %BB2 ]
30  %cnd = icmp eq i32 %var, 0
31  br i1 %cnd, label %BB1, label %END
32
33BB1:
34  %diffvar = add i32 %var, 1000
35  br label %BB1
36
37BB2:
38  %newvar1 = add i32 %var, 1
39  %newvar2 = add i32 %var, 2
40  br label %BB0
41
42END:
43  ; Equivalence of the ret depends on equivalence of %var.
44  ; Even if %var differs, we do not report a diff here, because
45  ; this is an indirect diff caused by another diff.
46  ret i32 %var
47}
48