1
; RUN: opt < %s -simplifycfg -S | FileCheck %s
3
define zeroext i1 @test1(i1 zeroext %flag, i32 %blksA, i32 %blksB, i32 %nblks) {
5
br i1 %flag, label %if.then, label %if.else
13
%cmp = icmp uge i32 %blksA, %nblks
14
%frombool1 = zext i1 %cmp to i8
18
%add = add i32 %nblks, %blksB
19
%cmp2 = icmp ule i32 %add, %blksA
20
%frombool3 = zext i1 %cmp2 to i8
24
%obeys.0 = phi i8 [ %frombool1, %if.then ], [ %frombool3, %if.else ]
25
%tobool4 = icmp ne i8 %obeys.0, 0
29
define zeroext i1 @test2(i1 zeroext %flag, i32 %blksA, i32 %blksB, i32 %nblks) {
31
br i1 %flag, label %if.then, label %if.else
39
%cmp = icmp uge i32 %blksA, %nblks
40
%frombool1 = zext i1 %cmp to i8
44
%add = add i32 %nblks, %blksB
45
%cmp2 = icmp uge i32 %blksA, %add
46
%frombool3 = zext i1 %cmp2 to i8
50
%obeys.0 = phi i8 [ %frombool1, %if.then ], [ %frombool3, %if.else ]
51
%tobool4 = icmp ne i8 %obeys.0, 0
55
declare i32 @foo(i32, i32) nounwind readnone
57
define i32 @test3(i1 zeroext %flag, i32 %x, i32 %y) {
59
br i1 %flag, label %if.then, label %if.else
62
%x0 = call i32 @foo(i32 %x, i32 0) nounwind readnone
63
%y0 = call i32 @foo(i32 %x, i32 1) nounwind readnone
67
%x1 = call i32 @foo(i32 %y, i32 0) nounwind readnone
68
%y1 = call i32 @foo(i32 %y, i32 1) nounwind readnone
72
%xx = phi i32 [ %x0, %if.then ], [ %x1, %if.else ]
73
%yy = phi i32 [ %y0, %if.then ], [ %y1, %if.else ]
74
%ret = add i32 %xx, %yy