1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py 2; RUN: opt < %s -simplifycfg -S | FileCheck %s 3; PR2540 4; Outval should end up with a select from 0/2, not all constants. 5 6target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:32:32" 7target triple = "i386-pc-linux-gnu" 8@g_37 = common global i32 0 ; <i32*> [#uses=1] 9@.str = internal constant [4 x i8] c"%d\0A\00" ; <[4 x i8]*> [#uses=1] 10 11define i32 @main() nounwind { 12; CHECK-LABEL: @main( 13; CHECK-NEXT: entry: 14; CHECK-NEXT: [[L:%.*]] = load i32, i32* @g_37, align 4 15; CHECK-NEXT: [[CMPA:%.*]] = icmp ne i32 [[L]], 0 16; CHECK-NEXT: br i1 [[CMPA]], label %func_1.exit, label %mooseblock 17; CHECK: mooseblock: 18; CHECK-NEXT: [[CMPB:%.*]] = icmp eq i1 [[CMPA]], false 19; CHECK-NEXT: [[BRMERGE:%.*]] = or i1 [[CMPB]], [[CMPA]] 20; CHECK-NEXT: [[DOTMUX:%.*]] = select i1 [[CMPB]], i32 0, i32 2 21; CHECK-NEXT: br i1 [[BRMERGE]], label %func_1.exit, label %infloop 22; CHECK: func_1.exit: 23; CHECK-NEXT: [[OUTVAL:%.*]] = phi i32 [ 1, %entry ], [ [[DOTMUX]], %mooseblock ] 24; CHECK-NEXT: [[POUT:%.*]] = tail call i32 (i8*, ...) @printf 25; CHECK-NEXT: ret i32 0 26; CHECK: infloop: 27; CHECK-NEXT: br label %infloop 28; 29entry: 30 %l = load i32, i32* @g_37, align 4 ; <i32> [#uses=1] 31 %cmpa = icmp ne i32 %l, 0 ; <i1> [#uses=3] 32 br i1 %cmpa, label %func_1.exit, label %mooseblock 33 34mooseblock: ; preds = %entry 35 %cmpb = icmp eq i1 %cmpa, false ; <i1> [#uses=2] 36 br i1 %cmpb, label %monkeyblock, label %beeblock 37 38monkeyblock: ; preds = %monkeyblock, %mooseblock 39 br i1 %cmpb, label %cowblock, label %monkeyblock 40 41beeblock: ; preds = %beeblock, %mooseblock 42 br i1 %cmpa, label %cowblock, label %beeblock 43 44cowblock: ; preds = %beeblock, %monkeyblock 45 %cowval = phi i32 [ 2, %beeblock ], [ 0, %monkeyblock ] ; <i32> [#uses=1] 46 br label %func_1.exit 47 48func_1.exit: ; preds = %cowblock, %entry 49 %outval = phi i32 [ %cowval, %cowblock ], [ 1, %entry ] ; <i32> [#uses=1] 50 %pout = tail call i32 (i8*, ...) @printf( i8* noalias getelementptr ([4 x i8], [4 x i8]* @.str, i32 0, i32 0), i32 %outval ) nounwind ; <i32> [#uses=0] 51 ret i32 0 52} 53 54declare i32 @printf(i8*, ...) nounwind 55 56