1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --function-signature
2 ; RUN: opt < %s -S -passes=ipsccp | FileCheck %s
4 ; testf() performs an unconditional branch on undef, as such the testf() return
5 ; value used in test1() will remain "unknown" and the following branch on it
6 ; replaced by unreachable. This is fine, as the call to testf() will already
7 ; trigger undefined behavior.
9 ; CHECK-LABEL: define {{[^@]+}}@test1() {
11 ; CHECK-NEXT: br label [[IF_THEN:%.*]]
13 ; CHECK-NEXT: [[CALL:%.*]] = call i1 @testf()
14 ; CHECK-NEXT: unreachable
18 if.then: ; preds = %entry, %if.then
19 %foo = phi i32 [ 0, %entry], [ %next, %if.then]
20 %next = add i32 %foo, 1
21 %call = call i1 @testf()
22 br i1 %call, label %if.end, label %if.then
24 if.end: ; preds = %if.then, %entry
28 define internal i1 @testf() {
29 ; CHECK-LABEL: define {{[^@]+}}@testf() {
31 ; CHECK-NEXT: unreachable
34 br i1 undef, label %if.then1, label %if.end3
36 if.then1: ; preds = %if.end
39 if.end3: ; preds = %if.then1, %entry
43 ; Call sites in unreachable blocks should not be a problem.
45 ; CHECK-LABEL: define {{[^@]+}}@test2() {
47 ; CHECK-NEXT: br label [[IF_END:%.*]]
49 ; CHECK-NEXT: [[CALL2:%.*]] = call i1 @testf()
50 ; CHECK-NEXT: ret i1 undef
55 if.then: ; preds = %entry, %if.then
56 %call = call i1 @testf()
57 br i1 %call, label %if.end, label %if.then
59 if.end: ; preds = %if.then, %entry
60 %call2 = call i1 @testf()