xref: /llvm-project/llvm/test/Transforms/SimplifyCFG/branch-fold-test.ll (revision d1d129356909af2f6fefd6f1b9335a39fe172e9a)
1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2; This test ensures that the simplifycfg pass continues to constant fold
3; terminator instructions.
4
5; RUN: opt < %s -passes=simplifycfg -simplifycfg-require-and-preserve-domtree=1 -S | FileCheck %s
6
7define i32 @test(i32 %A, i32 %B) {
8; CHECK-LABEL: @test(
9; CHECK-NEXT:  J:
10; CHECK-NEXT:    [[C:%.*]] = add i32 [[A:%.*]], 12
11; CHECK-NEXT:    [[D:%.*]] = add i32 [[C]], [[B:%.*]]
12; CHECK-NEXT:    ret i32 [[D]]
13;
14J:
15  %C = add i32 %A, 12             ; <i32> [#uses=2]
16  br i1 true, label %L, label %K
17L:              ; preds = %J
18  %D = add i32 %C, %B             ; <i32> [#uses=1]
19  ret i32 %D
20K:              ; preds = %J
21  %E = add i32 %C, %B             ; <i32> [#uses=1]
22  ret i32 %E
23}
24
25