|
| 1 | +; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 2 |
| 2 | +; RUN: opt < %s -passes=tailcallelim -verify-dom-info -S | FileCheck %s |
| 3 | + |
| 4 | +%struct.ListNode = type { i32, ptr } |
| 5 | + |
| 6 | +define noundef i32 @umin(ptr noundef readonly %a) { |
| 7 | +; CHECK-LABEL: define noundef i32 @umin |
| 8 | +; CHECK-SAME: (ptr noundef readonly [[A:%.*]]) { |
| 9 | +; CHECK-NEXT: entry: |
| 10 | +; CHECK-NEXT: [[TOBOOL_NOT:%.*]] = icmp eq ptr [[A]], null |
| 11 | +; CHECK-NEXT: br i1 [[TOBOOL_NOT]], label [[COMMON_RET6:%.*]], label [[IF_END:%.*]] |
| 12 | +; CHECK: common.ret6: |
| 13 | +; CHECK-NEXT: ret i32 -1 |
| 14 | +; CHECK: if.end: |
| 15 | +; CHECK-NEXT: [[TMP0:%.*]] = load i32, ptr [[A]], align 4 |
| 16 | +; CHECK-NEXT: [[NEXT:%.*]] = getelementptr inbounds [[STRUCT_LISTNODE:%.*]], ptr [[A]], i64 0, i32 1 |
| 17 | +; CHECK-NEXT: [[TMP1:%.*]] = load ptr, ptr [[NEXT]], align 8 |
| 18 | +; CHECK-NEXT: [[CALL:%.*]] = tail call noundef i32 @umin(ptr noundef [[TMP1]]) |
| 19 | +; CHECK-NEXT: [[DOTSROA_SPECULATED:%.*]] = tail call i32 @llvm.umin.i32(i32 [[TMP0]], i32 [[CALL]]) |
| 20 | +; CHECK-NEXT: ret i32 [[DOTSROA_SPECULATED]] |
| 21 | +; |
| 22 | +entry: |
| 23 | + %tobool.not = icmp eq ptr %a, null |
| 24 | + br i1 %tobool.not, label %common.ret6, label %if.end |
| 25 | + |
| 26 | +common.ret6: ; preds = %entry, %if.end |
| 27 | + %common.ret6.op = phi i32 [ %.sroa.speculated, %if.end ], [ -1, %entry ] |
| 28 | + ret i32 %common.ret6.op |
| 29 | + |
| 30 | +if.end: ; preds = %entry |
| 31 | + %0 = load i32, ptr %a |
| 32 | + %next = getelementptr inbounds %struct.ListNode, ptr %a, i64 0, i32 1 |
| 33 | + %1 = load ptr, ptr %next |
| 34 | + %call = tail call noundef i32 @umin(ptr noundef %1) |
| 35 | + %.sroa.speculated = tail call i32 @llvm.umin.i32(i32 %0, i32 %call) |
| 36 | + br label %common.ret6 |
| 37 | +} |
| 38 | + |
| 39 | +define noundef i32 @umax(ptr noundef readonly %a) { |
| 40 | +; CHECK-LABEL: define noundef i32 @umax |
| 41 | +; CHECK-SAME: (ptr noundef readonly [[A:%.*]]) { |
| 42 | +; CHECK-NEXT: entry: |
| 43 | +; CHECK-NEXT: [[TOBOOL_NOT:%.*]] = icmp eq ptr [[A]], null |
| 44 | +; CHECK-NEXT: br i1 [[TOBOOL_NOT]], label [[COMMON_RET6:%.*]], label [[IF_END:%.*]] |
| 45 | +; CHECK: common.ret6: |
| 46 | +; CHECK-NEXT: ret i32 0 |
| 47 | +; CHECK: if.end: |
| 48 | +; CHECK-NEXT: [[TMP0:%.*]] = load i32, ptr [[A]], align 4 |
| 49 | +; CHECK-NEXT: [[NEXT:%.*]] = getelementptr inbounds [[STRUCT_LISTNODE:%.*]], ptr [[A]], i64 0, i32 1 |
| 50 | +; CHECK-NEXT: [[TMP1:%.*]] = load ptr, ptr [[NEXT]], align 8 |
| 51 | +; CHECK-NEXT: [[CALL:%.*]] = tail call noundef i32 @umax(ptr noundef [[TMP1]]) |
| 52 | +; CHECK-NEXT: [[DOTSROA_SPECULATED:%.*]] = tail call i32 @llvm.umax.i32(i32 [[TMP0]], i32 [[CALL]]) |
| 53 | +; CHECK-NEXT: ret i32 [[DOTSROA_SPECULATED]] |
| 54 | +; |
| 55 | +entry: |
| 56 | + %tobool.not = icmp eq ptr %a, null |
| 57 | + br i1 %tobool.not, label %common.ret6, label %if.end |
| 58 | + |
| 59 | +common.ret6: ; preds = %entry, %if.end |
| 60 | + %common.ret6.op = phi i32 [ %.sroa.speculated, %if.end ], [ 0, %entry ] |
| 61 | + ret i32 %common.ret6.op |
| 62 | + |
| 63 | +if.end: ; preds = %entry |
| 64 | + %0 = load i32, ptr %a |
| 65 | + %next = getelementptr inbounds %struct.ListNode, ptr %a, i64 0, i32 1 |
| 66 | + %1 = load ptr, ptr %next |
| 67 | + %call = tail call noundef i32 @umax(ptr noundef %1) |
| 68 | + %.sroa.speculated = tail call i32 @llvm.umax.i32(i32 %0, i32 %call) |
| 69 | + br label %common.ret6 |
| 70 | +} |
| 71 | + |
| 72 | +define noundef i32 @smin(ptr noundef readonly %a) { |
| 73 | +; CHECK-LABEL: define noundef i32 @smin |
| 74 | +; CHECK-SAME: (ptr noundef readonly [[A:%.*]]) { |
| 75 | +; CHECK-NEXT: entry: |
| 76 | +; CHECK-NEXT: [[TOBOOL_NOT:%.*]] = icmp eq ptr [[A]], null |
| 77 | +; CHECK-NEXT: br i1 [[TOBOOL_NOT]], label [[COMMON_RET6:%.*]], label [[IF_END:%.*]] |
| 78 | +; CHECK: common.ret6: |
| 79 | +; CHECK-NEXT: ret i32 2147483647 |
| 80 | +; CHECK: if.end: |
| 81 | +; CHECK-NEXT: [[TMP0:%.*]] = load i32, ptr [[A]], align 4 |
| 82 | +; CHECK-NEXT: [[NEXT:%.*]] = getelementptr inbounds [[STRUCT_LISTNODE:%.*]], ptr [[A]], i64 0, i32 1 |
| 83 | +; CHECK-NEXT: [[TMP1:%.*]] = load ptr, ptr [[NEXT]], align 8 |
| 84 | +; CHECK-NEXT: [[CALL:%.*]] = tail call noundef i32 @smin(ptr noundef [[TMP1]]) |
| 85 | +; CHECK-NEXT: [[DOTSROA_SPECULATED:%.*]] = tail call i32 @llvm.smin.i32(i32 [[TMP0]], i32 [[CALL]]) |
| 86 | +; CHECK-NEXT: ret i32 [[DOTSROA_SPECULATED]] |
| 87 | +; |
| 88 | +entry: |
| 89 | + %tobool.not = icmp eq ptr %a, null |
| 90 | + br i1 %tobool.not, label %common.ret6, label %if.end |
| 91 | + |
| 92 | +common.ret6: ; preds = %entry, %if.end |
| 93 | + %common.ret6.op = phi i32 [ %.sroa.speculated, %if.end ], [ 2147483647, %entry ] |
| 94 | + ret i32 %common.ret6.op |
| 95 | + |
| 96 | +if.end: ; preds = %entry |
| 97 | + %0 = load i32, ptr %a |
| 98 | + %next = getelementptr inbounds %struct.ListNode, ptr %a, i64 0, i32 1 |
| 99 | + %1 = load ptr, ptr %next |
| 100 | + %call = tail call noundef i32 @smin(ptr noundef %1) |
| 101 | + %.sroa.speculated = tail call i32 @llvm.smin.i32(i32 %0, i32 %call) |
| 102 | + br label %common.ret6 |
| 103 | +} |
| 104 | + |
| 105 | +define noundef i32 @smax(ptr noundef readonly %a) { |
| 106 | +; CHECK-LABEL: define noundef i32 @smax |
| 107 | +; CHECK-SAME: (ptr noundef readonly [[A:%.*]]) { |
| 108 | +; CHECK-NEXT: entry: |
| 109 | +; CHECK-NEXT: [[TOBOOL_NOT:%.*]] = icmp eq ptr [[A]], null |
| 110 | +; CHECK-NEXT: br i1 [[TOBOOL_NOT]], label [[COMMON_RET6:%.*]], label [[IF_END:%.*]] |
| 111 | +; CHECK: common.ret6: |
| 112 | +; CHECK-NEXT: ret i32 -2147483648 |
| 113 | +; CHECK: if.end: |
| 114 | +; CHECK-NEXT: [[TMP0:%.*]] = load i32, ptr [[A]], align 4 |
| 115 | +; CHECK-NEXT: [[NEXT:%.*]] = getelementptr inbounds [[STRUCT_LISTNODE:%.*]], ptr [[A]], i64 0, i32 1 |
| 116 | +; CHECK-NEXT: [[TMP1:%.*]] = load ptr, ptr [[NEXT]], align 8 |
| 117 | +; CHECK-NEXT: [[CALL:%.*]] = tail call noundef i32 @smax(ptr noundef [[TMP1]]) |
| 118 | +; CHECK-NEXT: [[DOTSROA_SPECULATED:%.*]] = tail call i32 @llvm.smax.i32(i32 [[TMP0]], i32 [[CALL]]) |
| 119 | +; CHECK-NEXT: ret i32 [[DOTSROA_SPECULATED]] |
| 120 | +; |
| 121 | +entry: |
| 122 | + %tobool.not = icmp eq ptr %a, null |
| 123 | + br i1 %tobool.not, label %common.ret6, label %if.end |
| 124 | + |
| 125 | +common.ret6: ; preds = %entry, %if.end |
| 126 | + %common.ret6.op = phi i32 [ %.sroa.speculated, %if.end ], [ -2147483648, %entry ] |
| 127 | + ret i32 %common.ret6.op |
| 128 | + |
| 129 | +if.end: ; preds = %entry |
| 130 | + %0 = load i32, ptr %a |
| 131 | + %next = getelementptr inbounds %struct.ListNode, ptr %a, i64 0, i32 1 |
| 132 | + %1 = load ptr, ptr %next |
| 133 | + %call = tail call noundef i32 @smax(ptr noundef %1) |
| 134 | + %.sroa.speculated = tail call i32 @llvm.smax.i32(i32 %0, i32 %call) |
| 135 | + br label %common.ret6 |
| 136 | +} |
| 137 | + |
| 138 | +declare i32 @llvm.umin.i32(i32, i32) |
| 139 | +declare i32 @llvm.umax.i32(i32, i32) |
| 140 | +declare i32 @llvm.smin.i32(i32, i32) |
| 141 | +declare i32 @llvm.smax.i32(i32, i32) |
0 commit comments