|
| 1 | +; NOTE: Assertions have been autogenerated by utils/update_test_checks.py |
| 2 | +; RUN: opt < %s -instcombine -S | FileCheck %s |
| 3 | + |
| 4 | +declare { i64, i1 } @llvm.umul.with.overflow.i64(i64, i64) |
| 5 | +declare { i8, i1 } @llvm.umul.with.overflow.i8(i8, i8) |
| 6 | + |
| 7 | +define i1 @test_generic(i64 %a, i64 %b) { |
| 8 | +; CHECK-LABEL: @test_generic( |
| 9 | +; CHECK-NEXT: [[RES:%.*]] = tail call { i64, i1 } @llvm.umul.with.overflow.i64(i64 [[A:%.*]], i64 [[B:%.*]]) |
| 10 | +; CHECK-NEXT: [[OVERFLOW:%.*]] = extractvalue { i64, i1 } [[RES]], 1 |
| 11 | +; CHECK-NEXT: ret i1 [[OVERFLOW]] |
| 12 | +; |
| 13 | + %res = tail call { i64, i1 } @llvm.umul.with.overflow.i64(i64 %a, i64 %b) |
| 14 | + %overflow = extractvalue { i64, i1 } %res, 1 |
| 15 | + ret i1 %overflow |
| 16 | +} |
| 17 | + |
| 18 | +define i1 @test_constant0(i8 %a) { |
| 19 | +; CHECK-LABEL: @test_constant0( |
| 20 | +; CHECK-NEXT: ret i1 false |
| 21 | +; |
| 22 | + %res = tail call { i8, i1 } @llvm.umul.with.overflow.i8(i8 %a, i8 0) |
| 23 | + %overflow = extractvalue { i8, i1 } %res, 1 |
| 24 | + ret i1 %overflow |
| 25 | +} |
| 26 | + |
| 27 | +define i1 @test_constant1(i8 %a) { |
| 28 | +; CHECK-LABEL: @test_constant1( |
| 29 | +; CHECK-NEXT: ret i1 false |
| 30 | +; |
| 31 | + %res = tail call { i8, i1 } @llvm.umul.with.overflow.i8(i8 %a, i8 1) |
| 32 | + %overflow = extractvalue { i8, i1 } %res, 1 |
| 33 | + ret i1 %overflow |
| 34 | +} |
| 35 | + |
| 36 | +define i1 @test_constant2(i8 %a) { |
| 37 | +; CHECK-LABEL: @test_constant2( |
| 38 | +; CHECK-NEXT: [[RES:%.*]] = tail call { i8, i1 } @llvm.umul.with.overflow.i8(i8 [[A:%.*]], i8 2) |
| 39 | +; CHECK-NEXT: [[OVERFLOW:%.*]] = extractvalue { i8, i1 } [[RES]], 1 |
| 40 | +; CHECK-NEXT: ret i1 [[OVERFLOW]] |
| 41 | +; |
| 42 | + %res = tail call { i8, i1 } @llvm.umul.with.overflow.i8(i8 %a, i8 2) |
| 43 | + %overflow = extractvalue { i8, i1 } %res, 1 |
| 44 | + ret i1 %overflow |
| 45 | +} |
| 46 | + |
| 47 | +define i1 @test_constant3(i8 %a) { |
| 48 | +; CHECK-LABEL: @test_constant3( |
| 49 | +; CHECK-NEXT: [[RES:%.*]] = tail call { i8, i1 } @llvm.umul.with.overflow.i8(i8 [[A:%.*]], i8 3) |
| 50 | +; CHECK-NEXT: [[OVERFLOW:%.*]] = extractvalue { i8, i1 } [[RES]], 1 |
| 51 | +; CHECK-NEXT: ret i1 [[OVERFLOW]] |
| 52 | +; |
| 53 | + %res = tail call { i8, i1 } @llvm.umul.with.overflow.i8(i8 %a, i8 3) |
| 54 | + %overflow = extractvalue { i8, i1 } %res, 1 |
| 55 | + ret i1 %overflow |
| 56 | +} |
| 57 | + |
| 58 | +define i1 @test_constant127(i8 %a) { |
| 59 | +; CHECK-LABEL: @test_constant127( |
| 60 | +; CHECK-NEXT: [[RES:%.*]] = tail call { i8, i1 } @llvm.umul.with.overflow.i8(i8 [[A:%.*]], i8 127) |
| 61 | +; CHECK-NEXT: [[OVERFLOW:%.*]] = extractvalue { i8, i1 } [[RES]], 1 |
| 62 | +; CHECK-NEXT: ret i1 [[OVERFLOW]] |
| 63 | +; |
| 64 | + %res = tail call { i8, i1 } @llvm.umul.with.overflow.i8(i8 %a, i8 127) |
| 65 | + %overflow = extractvalue { i8, i1 } %res, 1 |
| 66 | + ret i1 %overflow |
| 67 | +} |
| 68 | + |
| 69 | +define i1 @test_constant128(i8 %a) { |
| 70 | +; CHECK-LABEL: @test_constant128( |
| 71 | +; CHECK-NEXT: [[RES:%.*]] = tail call { i8, i1 } @llvm.umul.with.overflow.i8(i8 [[A:%.*]], i8 -128) |
| 72 | +; CHECK-NEXT: [[OVERFLOW:%.*]] = extractvalue { i8, i1 } [[RES]], 1 |
| 73 | +; CHECK-NEXT: ret i1 [[OVERFLOW]] |
| 74 | +; |
| 75 | + %res = tail call { i8, i1 } @llvm.umul.with.overflow.i8(i8 %a, i8 128) |
| 76 | + %overflow = extractvalue { i8, i1 } %res, 1 |
| 77 | + ret i1 %overflow |
| 78 | +} |
| 79 | + |
| 80 | +define i1 @test_constant255(i8 %a) { |
| 81 | +; CHECK-LABEL: @test_constant255( |
| 82 | +; CHECK-NEXT: [[RES:%.*]] = tail call { i8, i1 } @llvm.umul.with.overflow.i8(i8 [[A:%.*]], i8 -1) |
| 83 | +; CHECK-NEXT: [[OVERFLOW:%.*]] = extractvalue { i8, i1 } [[RES]], 1 |
| 84 | +; CHECK-NEXT: ret i1 [[OVERFLOW]] |
| 85 | +; |
| 86 | + %res = tail call { i8, i1 } @llvm.umul.with.overflow.i8(i8 %a, i8 255) |
| 87 | + %overflow = extractvalue { i8, i1 } %res, 1 |
| 88 | + ret i1 %overflow |
| 89 | +} |
| 90 | + |
0 commit comments