1; RUN: opt < %s -S -ipsccp | FileCheck %s 2target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" 3target triple = "x86_64-unknown-linux-gnu" 4 5define void @fn2() { 6entry: 7 br label %if.end 8 9for.cond1: ; preds = %if.end, %for.end 10 br i1 undef, label %if.end, label %if.end 11 12if.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) 16 br label %for.cond1 17} 18 19define internal i32 @fn1(i32 %p1) { 20entry: 21 %tobool = icmp ne i32 %p1, 0 22 %cond = select i1 %tobool, i32 %p1, i32 %p1 23 ret i32 %cond 24} 25 26define void @fn_no_null_opt() #0 { 27entry: 28 br label %if.end 29 30for.cond1: ; preds = %if.end, %for.end 31 br i1 undef, label %if.end, label %if.end 32 33if.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) 37 br label %for.cond1 38} 39 40define internal i32 @fn0(i32 %p1) { 41entry: 42 %tobool = icmp ne i32 %p1, 0 43 %cond = select i1 %tobool, i32 %p1, i32 %p1 44 ret i32 %cond 45} 46 47attributes #0 = { "null-pointer-is-valid"="true" } 48 49; CHECK-LABEL: define void @fn2( 50; CHECK: call i32 @fn1(i32 undef) 51 52; CHECK-LABEL: define internal i32 @fn1( 53; CHECK:%[[COND:.*]] = select i1 undef, i32 undef, i32 undef 54; CHECK: ret i32 %[[COND]] 55 56; CHECK-LABEL: define void @fn_no_null_opt( 57; CHECK: call i32 @fn0(i32 %0) 58 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]] 63