1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py 2; RUN: opt < %s -instsimplify -S | FileCheck %s 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 { 17; CHECK-LABEL: @uadd_1( 18; CHECK-NEXT: ret { i8, i1 } { i8 -114, i1 false } 19; 20 %t = call {i8, i1} @llvm.uadd.with.overflow.i8(i8 42, i8 100) 21 ret {i8, i1} %t 22} 23 24define {i8, i1} @uadd_2() nounwind { 25; CHECK-LABEL: @uadd_2( 26; CHECK-NEXT: ret { i8, i1 } { i8 6, i1 true } 27; 28 %t = call {i8, i1} @llvm.uadd.with.overflow.i8(i8 142, i8 120) 29 ret {i8, i1} %t 30} 31 32define {i8, i1} @uadd_undef() nounwind { 33; CHECK-LABEL: @uadd_undef( 34; CHECK-NEXT: ret { i8, i1 } { i8 undef, i1 false } 35; 36 %t = call {i8, i1} @llvm.uadd.with.overflow.i8(i8 142, i8 undef) 37 ret {i8, i1} %t 38} 39 40;;----------------------------- 41;; usub 42;;----------------------------- 43 44define {i8, i1} @usub_1() nounwind { 45; CHECK-LABEL: @usub_1( 46; CHECK-NEXT: ret { i8, i1 } { i8 2, i1 false } 47; 48 %t = call {i8, i1} @llvm.usub.with.overflow.i8(i8 4, i8 2) 49 ret {i8, i1} %t 50} 51 52define {i8, i1} @usub_2() nounwind { 53; CHECK-LABEL: @usub_2( 54; CHECK-NEXT: ret { i8, i1 } { i8 -2, i1 true } 55; 56 %t = call {i8, i1} @llvm.usub.with.overflow.i8(i8 4, i8 6) 57 ret {i8, i1} %t 58} 59 60define {i8, i1} @usub_undef() nounwind { 61; CHECK-LABEL: @usub_undef( 62; CHECK-NEXT: ret { i8, i1 } { i8 undef, i1 false } 63; 64 %t = call {i8, i1} @llvm.usub.with.overflow.i8(i8 4, i8 undef) 65 ret {i8, i1} %t 66} 67 68;;----------------------------- 69;; umul 70;;----------------------------- 71 72define {i8, i1} @umul_1() nounwind { 73; CHECK-LABEL: @umul_1( 74; CHECK-NEXT: ret { i8, i1 } { i8 44, i1 true } 75; 76 %t = call {i8, i1} @llvm.umul.with.overflow.i8(i8 100, i8 3) 77 ret {i8, i1} %t 78} 79 80define {i8, i1} @umul_2() nounwind { 81; CHECK-LABEL: @umul_2( 82; CHECK-NEXT: ret { i8, i1 } { i8 -56, i1 false } 83; 84 %t = call {i8, i1} @llvm.umul.with.overflow.i8(i8 100, i8 2) 85 ret {i8, i1} %t 86} 87 88define {i8, i1} @umul_undef() nounwind { 89; CHECK-LABEL: @umul_undef( 90; CHECK-NEXT: ret { i8, i1 } zeroinitializer 91; 92 %t = call {i8, i1} @llvm.umul.with.overflow.i8(i8 undef, i8 2) 93 ret {i8, i1} %t 94} 95 96define {i8, i1} @umul_both_undef() nounwind { 97; CHECK-LABEL: @umul_both_undef( 98; CHECK-NEXT: ret { i8, i1 } zeroinitializer 99; 100 %t = call {i8, i1} @llvm.umul.with.overflow.i8(i8 undef, i8 undef) 101 ret {i8, i1} %t 102} 103 104;;----------------------------- 105;; sadd 106;;----------------------------- 107 108define {i8, i1} @sadd_1() nounwind { 109; CHECK-LABEL: @sadd_1( 110; CHECK-NEXT: ret { i8, i1 } { i8 44, i1 false } 111; 112 %t = call {i8, i1} @llvm.sadd.with.overflow.i8(i8 42, i8 2) 113 ret {i8, i1} %t 114} 115 116define {i8, i1} @sadd_2() nounwind { 117; CHECK-LABEL: @sadd_2( 118; CHECK-NEXT: ret { i8, i1 } { i8 -126, i1 true } 119; 120 %t = call {i8, i1} @llvm.sadd.with.overflow.i8(i8 120, i8 10) 121 ret {i8, i1} %t 122} 123 124define {i8, i1} @sadd_3() nounwind { 125; CHECK-LABEL: @sadd_3( 126; CHECK-NEXT: ret { i8, i1 } { i8 -110, i1 false } 127; 128 %t = call {i8, i1} @llvm.sadd.with.overflow.i8(i8 -120, i8 10) 129 ret {i8, i1} %t 130} 131 132define {i8, i1} @sadd_4() nounwind { 133; CHECK-LABEL: @sadd_4( 134; CHECK-NEXT: ret { i8, i1 } { i8 126, i1 true } 135; 136 %t = call {i8, i1} @llvm.sadd.with.overflow.i8(i8 -120, i8 -10) 137 ret {i8, i1} %t 138} 139 140define {i8, i1} @sadd_5() nounwind { 141; CHECK-LABEL: @sadd_5( 142; CHECK-NEXT: ret { i8, i1 } { i8 -8, i1 false } 143; 144 %t = call {i8, i1} @llvm.sadd.with.overflow.i8(i8 2, i8 -10) 145 ret {i8, i1} %t 146} 147 148define {i8, i1} @sadd_undef() nounwind { 149; CHECK-LABEL: @sadd_undef( 150; CHECK-NEXT: ret { i8, i1 } { i8 undef, i1 false } 151; 152 %t = call {i8, i1} @llvm.sadd.with.overflow.i8(i8 undef, i8 -10) 153 ret {i8, i1} %t 154} 155 156;;----------------------------- 157;; ssub 158;;----------------------------- 159 160define {i8, i1} @ssub_1() nounwind { 161; CHECK-LABEL: @ssub_1( 162; CHECK-NEXT: ret { i8, i1 } { i8 2, i1 false } 163; 164 %t = call {i8, i1} @llvm.ssub.with.overflow.i8(i8 4, i8 2) 165 ret {i8, i1} %t 166} 167 168define {i8, i1} @ssub_2() nounwind { 169; CHECK-LABEL: @ssub_2( 170; CHECK-NEXT: ret { i8, i1 } { i8 -2, i1 false } 171; 172 %t = call {i8, i1} @llvm.ssub.with.overflow.i8(i8 4, i8 6) 173 ret {i8, i1} %t 174} 175 176define {i8, i1} @ssub_3() nounwind { 177; CHECK-LABEL: @ssub_3( 178; CHECK-NEXT: ret { i8, i1 } { i8 126, i1 true } 179; 180 %t = call {i8, i1} @llvm.ssub.with.overflow.i8(i8 -10, i8 120) 181 ret {i8, i1} %t 182} 183 184define {i8, i1} @ssub_3b() nounwind { 185; CHECK-LABEL: @ssub_3b( 186; CHECK-NEXT: ret { i8, i1 } { i8 -20, i1 false } 187; 188 %t = call {i8, i1} @llvm.ssub.with.overflow.i8(i8 -10, i8 10) 189 ret {i8, i1} %t 190} 191 192define {i8, i1} @ssub_4() nounwind { 193; CHECK-LABEL: @ssub_4( 194; CHECK-NEXT: ret { i8, i1 } { i8 -126, i1 true } 195; 196 %t = call {i8, i1} @llvm.ssub.with.overflow.i8(i8 120, i8 -10) 197 ret {i8, i1} %t 198} 199 200define {i8, i1} @ssub_4b() nounwind { 201; CHECK-LABEL: @ssub_4b( 202; CHECK-NEXT: ret { i8, i1 } { i8 30, i1 false } 203; 204 %t = call {i8, i1} @llvm.ssub.with.overflow.i8(i8 20, i8 -10) 205 ret {i8, i1} %t 206} 207 208define {i8, i1} @ssub_5() nounwind { 209; CHECK-LABEL: @ssub_5( 210; CHECK-NEXT: ret { i8, i1 } { i8 -10, i1 false } 211; 212 %t = call {i8, i1} @llvm.ssub.with.overflow.i8(i8 -20, i8 -10) 213 ret {i8, i1} %t 214} 215 216define {i8, i1} @ssub_undef() nounwind { 217; CHECK-LABEL: @ssub_undef( 218; CHECK-NEXT: ret { i8, i1 } { i8 undef, i1 false } 219; 220 %t = call {i8, i1} @llvm.ssub.with.overflow.i8(i8 undef, i8 -10) 221 ret {i8, i1} %t 222} 223 224;;----------------------------- 225;; smul 226;;----------------------------- 227 228define {i8, i1} @smul_1() nounwind { 229; CHECK-LABEL: @smul_1( 230; CHECK-NEXT: ret { i8, i1 } { i8 -56, i1 true } 231; 232 %t = call {i8, i1} @llvm.smul.with.overflow.i8(i8 -20, i8 -10) 233 ret {i8, i1} %t 234} 235 236define {i8, i1} @smul_undef() nounwind { 237; CHECK-LABEL: @smul_undef( 238; CHECK-NEXT: ret { i8, i1 } zeroinitializer 239; 240 %t = call {i8, i1} @llvm.smul.with.overflow.i8(i8 -20, i8 undef) 241 ret {i8, i1} %t 242} 243 244define {i8, i1} @smul_both_undef() nounwind { 245; CHECK-LABEL: @smul_both_undef( 246; CHECK-NEXT: ret { i8, i1 } zeroinitializer 247; 248 %t = call {i8, i1} @llvm.smul.with.overflow.i8(i8 undef, i8 undef) 249 ret {i8, i1} %t 250} 251