xref: /llvm-project/llvm/test/Transforms/DFAJumpThreading/dfa-constant-propagation.ll (revision 641a684fa0930074b32f17672e69486943a80c81)
1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2; RUN: opt -S -passes=dfa-jump-threading,sccp,simplifycfg %s | FileCheck %s
3
4; This test checks that a constant propagation is applied for a basic loop.
5; Related to bug 44679.
6define i32 @test(i32 %a) {
7; CHECK-LABEL: @test(
8; CHECK-NEXT:  entry:
9; CHECK-NEXT:    ret i32 3
10;
11entry:
12  br label %while.cond
13
14while.cond:
15  %num = phi i32 [ 0, %entry ], [ %add, %case1 ]
16  %state = phi i32 [ 1, %entry ], [ %state.next, %case1 ]
17  switch i32 %state, label %end [
18  i32 1, label %case1
19  i32 2, label %case2
20  ]
21
22case1:
23  %state.next = phi i32 [ 3, %case2 ], [ 2, %while.cond ]
24  %add = add nsw i32 %num, %state
25  br label %while.cond
26
27case2:
28  br label %case1
29
30end:
31  ret i32 %num
32}
33