1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --function-signature --scrub-attributes
2 ; RUN: opt < %s -S -ipsccp | FileCheck %s
3 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
4 target triple = "x86_64-unknown-linux-gnu"
6 define void @fn2(i32* %P) {
7 ; CHECK-LABEL: define {{[^@]+}}@fn2
8 ; CHECK-SAME: (i32* [[P:%.*]])
10 ; CHECK-NEXT: br label [[IF_END:%.*]]
12 ; CHECK-NEXT: br i1 false, label [[IF_END]], label [[IF_END]]
14 ; CHECK-NEXT: [[CALL:%.*]] = call i32 @fn1(i32 undef)
15 ; CHECK-NEXT: store i32 [[CALL]], i32* [[P]]
16 ; CHECK-NEXT: br label [[FOR_COND1:%.*]]
21 for.cond1: ; preds = %if.end, %for.end
22 br i1 undef, label %if.end, label %if.end
24 if.end: ; preds = %lbl, %for.cond1
25 %e.2 = phi i32* [ undef, %entry ], [ null, %for.cond1 ], [ null, %for.cond1 ]
26 %0 = load i32, i32* %e.2, align 4
27 %call = call i32 @fn1(i32 %0)
28 store i32 %call, i32* %P
32 define internal i32 @fn1(i32 %p1) {
33 ; CHECK-LABEL: define {{[^@]+}}@fn1
34 ; CHECK-SAME: (i32 [[P1:%.*]])
36 ; CHECK-NEXT: [[TOBOOL:%.*]] = icmp ne i32 undef, 0
37 ; CHECK-NEXT: [[COND:%.*]] = select i1 [[TOBOOL]], i32 undef, i32 undef
38 ; CHECK-NEXT: ret i32 [[COND]]
41 %tobool = icmp ne i32 %p1, 0
42 %cond = select i1 %tobool, i32 %p1, i32 %p1
46 define void @fn_no_null_opt(i32* %P) #0 {
47 ; CHECK-LABEL: define {{[^@]+}}@fn_no_null_opt
48 ; CHECK-SAME: (i32* [[P:%.*]])
50 ; CHECK-NEXT: br label [[IF_END:%.*]]
52 ; CHECK-NEXT: br i1 false, label [[IF_END]], label [[IF_END]]
54 ; CHECK-NEXT: [[TMP0:%.*]] = load i32, i32* null, align 4
55 ; CHECK-NEXT: [[CALL:%.*]] = call i32 @fn0(i32 [[TMP0]])
56 ; CHECK-NEXT: store i32 [[CALL]], i32* [[P]]
57 ; CHECK-NEXT: br label [[FOR_COND1:%.*]]
62 for.cond1: ; preds = %if.end, %for.end
63 br i1 undef, label %if.end, label %if.end
65 if.end: ; preds = %lbl, %for.cond1
66 %e.2 = phi i32* [ undef, %entry ], [ null, %for.cond1 ], [ null, %for.cond1 ]
67 %0 = load i32, i32* %e.2, align 4
68 %call = call i32 @fn0(i32 %0)
69 store i32 %call, i32* %P
73 define internal i32 @fn0(i32 %p1) {
74 ; CHECK-LABEL: define {{[^@]+}}@fn0
75 ; CHECK-SAME: (i32 [[P1:%.*]])
77 ; CHECK-NEXT: [[TOBOOL:%.*]] = icmp ne i32 [[P1]], 0
78 ; CHECK-NEXT: [[COND:%.*]] = select i1 [[TOBOOL]], i32 [[P1]], i32 [[P1]]
79 ; CHECK-NEXT: ret i32 [[COND]]
82 %tobool = icmp ne i32 %p1, 0
83 %cond = select i1 %tobool, i32 %p1, i32 %p1
87 attributes #0 = { null_pointer_is_valid }