1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt < %s -S -passes=instcombine | FileCheck %s
4 ; Derived from gcc.c-torture/execute/frame-address.c
6 define i32 @func(ptr %c, ptr %f) nounwind uwtable readnone noinline ssp {
9 ; CHECK-NEXT: [[D:%.*]] = alloca i8, align 1
10 ; CHECK-NEXT: store i8 0, ptr [[D]], align 1
11 ; CHECK-NEXT: [[CMP:%.*]] = icmp ugt ptr [[D]], [[C:%.*]]
12 ; CHECK-NEXT: br i1 [[CMP]], label [[IF_ELSE:%.*]], label [[IF_THEN:%.*]]
14 ; CHECK-NEXT: [[CMP2:%.*]] = icmp ule ptr [[D]], [[F:%.*]]
15 ; CHECK-NEXT: [[NOT_CMP1:%.*]] = icmp uge ptr [[C]], [[F]]
16 ; CHECK-NEXT: [[DOTCMP2:%.*]] = and i1 [[CMP2]], [[NOT_CMP1]]
17 ; CHECK-NEXT: br label [[RETURN:%.*]]
19 ; CHECK-NEXT: [[CMP5:%.*]] = icmp uge ptr [[D]], [[F]]
20 ; CHECK-NEXT: [[NOT_CMP3:%.*]] = icmp ule ptr [[C]], [[F]]
21 ; CHECK-NEXT: [[DOTCMP5:%.*]] = and i1 [[CMP5]], [[NOT_CMP3]]
22 ; CHECK-NEXT: br label [[RETURN]]
24 ; CHECK-NEXT: [[RETVAL_0_IN:%.*]] = phi i1 [ [[DOTCMP2]], [[IF_THEN]] ], [ [[DOTCMP5]], [[IF_ELSE]] ]
25 ; CHECK-NEXT: [[RETVAL_0:%.*]] = zext i1 [[RETVAL_0_IN]] to i32
26 ; CHECK-NEXT: ret i32 [[RETVAL_0]]
29 %d = alloca i8, align 1
30 store i8 0, ptr %d, align 1
31 %cmp = icmp ugt ptr %d, %c
32 br i1 %cmp, label %if.else, label %if.then
34 if.then: ; preds = %entry
35 %cmp2 = icmp ule ptr %d, %f
36 %not.cmp1 = icmp uge ptr %c, %f
37 %.cmp2 = and i1 %cmp2, %not.cmp1
38 %land.ext = zext i1 %.cmp2 to i32
41 if.else: ; preds = %entry
42 %cmp5 = icmp uge ptr %d, %f
43 %not.cmp3 = icmp ule ptr %c, %f
44 %.cmp5 = and i1 %cmp5, %not.cmp3
45 %land.ext7 = zext i1 %.cmp5 to i32
48 return: ; preds = %if.else, %if.then
49 %retval.0 = phi i32 [ %land.ext, %if.then ], [ %land.ext7, %if.else ]
53 define i32 @func_logical(ptr %c, ptr %f) nounwind uwtable readnone noinline ssp {
54 ; CHECK-LABEL: @func_logical(
56 ; CHECK-NEXT: [[D:%.*]] = alloca i8, align 1
57 ; CHECK-NEXT: store i8 0, ptr [[D]], align 1
58 ; CHECK-NEXT: [[CMP:%.*]] = icmp ugt ptr [[D]], [[C:%.*]]
59 ; CHECK-NEXT: br i1 [[CMP]], label [[IF_ELSE:%.*]], label [[IF_THEN:%.*]]
61 ; CHECK-NEXT: [[CMP2:%.*]] = icmp ule ptr [[D]], [[F:%.*]]
62 ; CHECK-NEXT: [[NOT_CMP1:%.*]] = icmp uge ptr [[C]], [[F]]
63 ; CHECK-NEXT: [[DOTCMP2:%.*]] = and i1 [[CMP2]], [[NOT_CMP1]]
64 ; CHECK-NEXT: br label [[RETURN:%.*]]
66 ; CHECK-NEXT: [[CMP5:%.*]] = icmp uge ptr [[D]], [[F]]
67 ; CHECK-NEXT: [[NOT_CMP3:%.*]] = icmp ule ptr [[C]], [[F]]
68 ; CHECK-NEXT: [[DOTCMP5:%.*]] = and i1 [[CMP5]], [[NOT_CMP3]]
69 ; CHECK-NEXT: br label [[RETURN]]
71 ; CHECK-NEXT: [[RETVAL_0_IN:%.*]] = phi i1 [ [[DOTCMP2]], [[IF_THEN]] ], [ [[DOTCMP5]], [[IF_ELSE]] ]
72 ; CHECK-NEXT: [[RETVAL_0:%.*]] = zext i1 [[RETVAL_0_IN]] to i32
73 ; CHECK-NEXT: ret i32 [[RETVAL_0]]
76 %d = alloca i8, align 1
77 store i8 0, ptr %d, align 1
78 %cmp = icmp ugt ptr %d, %c
79 br i1 %cmp, label %if.else, label %if.then
81 if.then: ; preds = %entry
82 %cmp2 = icmp ule ptr %d, %f
83 %not.cmp1 = icmp uge ptr %c, %f
84 %.cmp2 = select i1 %cmp2, i1 %not.cmp1, i1 false
85 %land.ext = zext i1 %.cmp2 to i32
88 if.else: ; preds = %entry
89 %cmp5 = icmp uge ptr %d, %f
90 %not.cmp3 = icmp ule ptr %c, %f
91 %.cmp5 = select i1 %cmp5, i1 %not.cmp3, i1 false
92 %land.ext7 = zext i1 %.cmp5 to i32
95 return: ; preds = %if.else, %if.then
96 %retval.0 = phi i32 [ %land.ext, %if.then ], [ %land.ext7, %if.else ]