1 ; RUN: opt < %s -S -ipsccp | FileCheck %s
2 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
3 target triple = "x86_64-unknown-linux-gnu"
9 for.cond1: ; preds = %if.end, %for.end
10 br i1 undef, label %if.end, label %if.end
12 if.end: ; preds = %lbl, %for.cond1
13 %e.2 = phi i32* [ undef, %entry ], [ null, %for.cond1 ], [ null, %for.cond1 ]
14 %0 = load i32, i32* %e.2, align 4
15 %call = call i32 @fn1(i32 %0)
19 define internal i32 @fn1(i32 %p1) {
21 %tobool = icmp ne i32 %p1, 0
22 %cond = select i1 %tobool, i32 %p1, i32 %p1
26 define void @fn_no_null_opt() #0 {
30 for.cond1: ; preds = %if.end, %for.end
31 br i1 undef, label %if.end, label %if.end
33 if.end: ; preds = %lbl, %for.cond1
34 %e.2 = phi i32* [ undef, %entry ], [ null, %for.cond1 ], [ null, %for.cond1 ]
35 %0 = load i32, i32* %e.2, align 4
36 %call = call i32 @fn0(i32 %0)
40 define internal i32 @fn0(i32 %p1) {
42 %tobool = icmp ne i32 %p1, 0
43 %cond = select i1 %tobool, i32 %p1, i32 %p1
47 attributes #0 = { "null-pointer-is-valid"="true" }
49 ; CHECK-LABEL: define void @fn2(
50 ; CHECK: call i32 @fn1(i32 undef)
52 ; CHECK-LABEL: define internal i32 @fn1(
53 ; CHECK:%[[COND:.*]] = select i1 undef, i32 undef, i32 undef
54 ; CHECK: ret i32 %[[COND]]
56 ; CHECK-LABEL: define void @fn_no_null_opt(
57 ; CHECK: call i32 @fn0(i32 %0)
59 ; CHECK-LABEL: define internal i32 @fn0(
60 ; CHECK:%[[TOBOOL:.*]] = icmp ne i32 %p1, 0
61 ; CHECK:%[[COND:.*]] = select i1 %[[TOBOOL]], i32 %p1, i32 %p1
62 ; CHECK: ret i32 %[[COND]]