1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt < %s -instcombine -S | FileCheck %s
4 declare { i64, i1 } @llvm.umul.with.overflow.i64(i64, i64)
5 declare { i8, i1 } @llvm.umul.with.overflow.i8(i8, i8)
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]]
13 %res = tail call { i64, i1 } @llvm.umul.with.overflow.i64(i64 %a, i64 %b)
14 %overflow = extractvalue { i64, i1 } %res, 1
18 define i1 @test_constant0(i8 %a) {
19 ; CHECK-LABEL: @test_constant0(
20 ; CHECK-NEXT: ret i1 false
22 %res = tail call { i8, i1 } @llvm.umul.with.overflow.i8(i8 %a, i8 0)
23 %overflow = extractvalue { i8, i1 } %res, 1
27 define i1 @test_constant1(i8 %a) {
28 ; CHECK-LABEL: @test_constant1(
29 ; CHECK-NEXT: ret i1 false
31 %res = tail call { i8, i1 } @llvm.umul.with.overflow.i8(i8 %a, i8 1)
32 %overflow = extractvalue { i8, i1 } %res, 1
36 define i1 @test_constant2(i8 %a) {
37 ; CHECK-LABEL: @test_constant2(
38 ; CHECK-NEXT: [[OVERFLOW:%.*]] = icmp slt i8 [[A:%.*]], 0
39 ; CHECK-NEXT: ret i1 [[OVERFLOW]]
41 %res = tail call { i8, i1 } @llvm.umul.with.overflow.i8(i8 %a, i8 2)
42 %overflow = extractvalue { i8, i1 } %res, 1
46 define i1 @test_constant3(i8 %a) {
47 ; CHECK-LABEL: @test_constant3(
48 ; CHECK-NEXT: [[OVERFLOW:%.*]] = icmp ugt i8 [[A:%.*]], 85
49 ; CHECK-NEXT: ret i1 [[OVERFLOW]]
51 %res = tail call { i8, i1 } @llvm.umul.with.overflow.i8(i8 %a, i8 3)
52 %overflow = extractvalue { i8, i1 } %res, 1
56 define i1 @test_constant4(i8 %a) {
57 ; CHECK-LABEL: @test_constant4(
58 ; CHECK-NEXT: [[OVERFLOW:%.*]] = icmp ugt i8 [[A:%.*]], 63
59 ; CHECK-NEXT: ret i1 [[OVERFLOW]]
61 %res = tail call { i8, i1 } @llvm.umul.with.overflow.i8(i8 %a, i8 4)
62 %overflow = extractvalue { i8, i1 } %res, 1
67 define i1 @test_constant127(i8 %a) {
68 ; CHECK-LABEL: @test_constant127(
69 ; CHECK-NEXT: [[OVERFLOW:%.*]] = icmp ugt i8 [[A:%.*]], 2
70 ; CHECK-NEXT: ret i1 [[OVERFLOW]]
72 %res = tail call { i8, i1 } @llvm.umul.with.overflow.i8(i8 %a, i8 127)
73 %overflow = extractvalue { i8, i1 } %res, 1
77 define i1 @test_constant128(i8 %a) {
78 ; CHECK-LABEL: @test_constant128(
79 ; CHECK-NEXT: [[OVERFLOW:%.*]] = icmp ugt i8 [[A:%.*]], 1
80 ; CHECK-NEXT: ret i1 [[OVERFLOW]]
82 %res = tail call { i8, i1 } @llvm.umul.with.overflow.i8(i8 %a, i8 128)
83 %overflow = extractvalue { i8, i1 } %res, 1
87 define i1 @test_constant255(i8 %a) {
88 ; CHECK-LABEL: @test_constant255(
89 ; CHECK-NEXT: [[OVERFLOW:%.*]] = icmp ugt i8 [[A:%.*]], 1
90 ; CHECK-NEXT: ret i1 [[OVERFLOW]]
92 %res = tail call { i8, i1 } @llvm.umul.with.overflow.i8(i8 %a, i8 255)
93 %overflow = extractvalue { i8, i1 } %res, 1