1; RUN: opt < %s -constprop -S | FileCheck %s 2 3 4declare {i8, i1} @llvm.uadd.with.overflow.i8(i8, i8) 5declare {i8, i1} @llvm.usub.with.overflow.i8(i8, i8) 6declare {i8, i1} @llvm.umul.with.overflow.i8(i8, i8) 7 8declare {i8, i1} @llvm.sadd.with.overflow.i8(i8, i8) 9declare {i8, i1} @llvm.ssub.with.overflow.i8(i8, i8) 10declare {i8, i1} @llvm.smul.with.overflow.i8(i8, i8) 11 12;;----------------------------- 13;; uadd 14;;----------------------------- 15 16define {i8, i1} @uadd_1() nounwind { 17entry: 18 %t = call {i8, i1} @llvm.uadd.with.overflow.i8(i8 42, i8 100) 19 ret {i8, i1} %t 20 21; CHECK-LABEL: @uadd_1( 22; CHECK: ret { i8, i1 } { i8 -114, i1 false } 23} 24 25define {i8, i1} @uadd_2() nounwind { 26entry: 27 %t = call {i8, i1} @llvm.uadd.with.overflow.i8(i8 142, i8 120) 28 ret {i8, i1} %t 29 30; CHECK-LABEL: @uadd_2( 31; CHECK: ret { i8, i1 } { i8 6, i1 true } 32} 33 34;;----------------------------- 35;; usub 36;;----------------------------- 37 38define {i8, i1} @usub_1() nounwind { 39entry: 40 %t = call {i8, i1} @llvm.usub.with.overflow.i8(i8 4, i8 2) 41 ret {i8, i1} %t 42 43; CHECK-LABEL: @usub_1( 44; CHECK: ret { i8, i1 } { i8 2, i1 false } 45} 46 47define {i8, i1} @usub_2() nounwind { 48entry: 49 %t = call {i8, i1} @llvm.usub.with.overflow.i8(i8 4, i8 6) 50 ret {i8, i1} %t 51 52; CHECK-LABEL: @usub_2( 53; CHECK: ret { i8, i1 } { i8 -2, i1 true } 54} 55 56;;----------------------------- 57;; umul 58;;----------------------------- 59 60define {i8, i1} @umul_1() nounwind { 61entry: 62 %t = call {i8, i1} @llvm.umul.with.overflow.i8(i8 100, i8 3) 63 ret {i8, i1} %t 64 65; CHECK-LABEL: @umul_1( 66; CHECK: ret { i8, i1 } { i8 44, i1 true } 67} 68 69define {i8, i1} @umul_2() nounwind { 70entry: 71 %t = call {i8, i1} @llvm.umul.with.overflow.i8(i8 100, i8 2) 72 ret {i8, i1} %t 73 74; CHECK-LABEL: @umul_2( 75; CHECK: ret { i8, i1 } { i8 -56, i1 false } 76} 77 78;;----------------------------- 79;; sadd 80;;----------------------------- 81 82define {i8, i1} @sadd_1() nounwind { 83entry: 84 %t = call {i8, i1} @llvm.sadd.with.overflow.i8(i8 42, i8 2) 85 ret {i8, i1} %t 86 87; CHECK-LABEL: @sadd_1( 88; CHECK: ret { i8, i1 } { i8 44, i1 false } 89} 90 91define {i8, i1} @sadd_2() nounwind { 92entry: 93 %t = call {i8, i1} @llvm.sadd.with.overflow.i8(i8 120, i8 10) 94 ret {i8, i1} %t 95 96; CHECK-LABEL: @sadd_2( 97; CHECK: ret { i8, i1 } { i8 -126, i1 true } 98} 99 100define {i8, i1} @sadd_3() nounwind { 101entry: 102 %t = call {i8, i1} @llvm.sadd.with.overflow.i8(i8 -120, i8 10) 103 ret {i8, i1} %t 104 105; CHECK-LABEL: @sadd_3( 106; CHECK: ret { i8, i1 } { i8 -110, i1 false } 107} 108 109define {i8, i1} @sadd_4() nounwind { 110entry: 111 %t = call {i8, i1} @llvm.sadd.with.overflow.i8(i8 -120, i8 -10) 112 ret {i8, i1} %t 113 114; CHECK-LABEL: @sadd_4( 115; CHECK: ret { i8, i1 } { i8 126, i1 true } 116} 117 118define {i8, i1} @sadd_5() nounwind { 119entry: 120 %t = call {i8, i1} @llvm.sadd.with.overflow.i8(i8 2, i8 -10) 121 ret {i8, i1} %t 122 123; CHECK-LABEL: @sadd_5( 124; CHECK: ret { i8, i1 } { i8 -8, i1 false } 125} 126 127 128;;----------------------------- 129;; ssub 130;;----------------------------- 131 132define {i8, i1} @ssub_1() nounwind { 133entry: 134 %t = call {i8, i1} @llvm.ssub.with.overflow.i8(i8 4, i8 2) 135 ret {i8, i1} %t 136 137; CHECK-LABEL: @ssub_1( 138; CHECK: ret { i8, i1 } { i8 2, i1 false } 139} 140 141define {i8, i1} @ssub_2() nounwind { 142entry: 143 %t = call {i8, i1} @llvm.ssub.with.overflow.i8(i8 4, i8 6) 144 ret {i8, i1} %t 145 146; CHECK-LABEL: @ssub_2( 147; CHECK: ret { i8, i1 } { i8 -2, i1 false } 148} 149 150define {i8, i1} @ssub_3() nounwind { 151entry: 152 %t = call {i8, i1} @llvm.ssub.with.overflow.i8(i8 -10, i8 120) 153 ret {i8, i1} %t 154 155; CHECK-LABEL: @ssub_3( 156; CHECK: ret { i8, i1 } { i8 126, i1 true } 157} 158 159define {i8, i1} @ssub_3b() nounwind { 160entry: 161 %t = call {i8, i1} @llvm.ssub.with.overflow.i8(i8 -10, i8 10) 162 ret {i8, i1} %t 163 164; CHECK-LABEL: @ssub_3b( 165; CHECK: ret { i8, i1 } { i8 -20, i1 false } 166} 167 168define {i8, i1} @ssub_4() nounwind { 169entry: 170 %t = call {i8, i1} @llvm.ssub.with.overflow.i8(i8 120, i8 -10) 171 ret {i8, i1} %t 172 173; CHECK-LABEL: @ssub_4( 174; CHECK: ret { i8, i1 } { i8 -126, i1 true } 175} 176 177define {i8, i1} @ssub_4b() nounwind { 178entry: 179 %t = call {i8, i1} @llvm.ssub.with.overflow.i8(i8 20, i8 -10) 180 ret {i8, i1} %t 181 182; CHECK-LABEL: @ssub_4b( 183; CHECK: ret { i8, i1 } { i8 30, i1 false } 184} 185 186define {i8, i1} @ssub_5() nounwind { 187entry: 188 %t = call {i8, i1} @llvm.ssub.with.overflow.i8(i8 -20, i8 -10) 189 ret {i8, i1} %t 190 191; CHECK-LABEL: @ssub_5( 192; CHECK: ret { i8, i1 } { i8 -10, i1 false } 193} 194 195;;----------------------------- 196;; smul 197;;----------------------------- 198 199; rdar://8501501 200define {i8, i1} @smul_1() nounwind { 201entry: 202 %t = call {i8, i1} @llvm.smul.with.overflow.i8(i8 -20, i8 -10) 203 ret {i8, i1} %t 204 205; CHECK-LABEL: @smul_1( 206; CHECK: ret { i8, i1 } { i8 -56, i1 true } 207} 208