1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt < %s -passes=simplifycfg -simplifycfg-require-and-preserve-domtree=1 -S | FileCheck %s
4 ; Outval should end up with a select from 0/2, not all constants.
6 target 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"
7 target triple = "i386-pc-linux-gnu"
8 @g_37 = common global i32 0 ; <ptr> [#uses=1]
9 @.str = internal constant [4 x i8] c"%d\0A\00" ; <ptr> [#uses=1]
11 define i32 @main() nounwind {
14 ; CHECK-NEXT: [[L:%.*]] = load i32, ptr @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:%.*]]
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:%.*]]
23 ; CHECK-NEXT: [[OUTVAL:%.*]] = phi i32 [ 1, [[ENTRY:%.*]] ], [ [[DOTMUX]], [[MOOSEBLOCK]] ]
24 ; CHECK-NEXT: [[POUT:%.*]] = tail call i32 (ptr, ...) @printf(ptr noalias @.str, i32 [[OUTVAL]]) #[[ATTR0:[0-9]+]]
25 ; CHECK-NEXT: ret i32 0
27 ; CHECK-NEXT: br label [[INFLOOP]]
30 %l = load i32, ptr @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
34 mooseblock: ; preds = %entry
35 %cmpb = icmp eq i1 %cmpa, false ; <i1> [#uses=2]
36 br i1 %cmpb, label %monkeyblock, label %beeblock
38 monkeyblock: ; preds = %monkeyblock, %mooseblock
39 br i1 %cmpb, label %cowblock, label %monkeyblock
41 beeblock: ; preds = %beeblock, %mooseblock
42 br i1 %cmpa, label %cowblock, label %beeblock
44 cowblock: ; preds = %beeblock, %monkeyblock
45 %cowval = phi i32 [ 2, %beeblock ], [ 0, %monkeyblock ] ; <i32> [#uses=1]
48 func_1.exit: ; preds = %cowblock, %entry
49 %outval = phi i32 [ %cowval, %cowblock ], [ 1, %entry ] ; <i32> [#uses=1]
50 %pout = tail call i32 (ptr, ...) @printf( ptr noalias @.str, i32 %outval ) nounwind ; <i32> [#uses=0]
54 declare i32 @printf(ptr, ...) nounwind