[llvm] e80a21d - [test][instcombine] Add test cases for all x.with.overflow overflow checks
Philip Reames via llvm-commits
llvm-commits at lists.llvm.org
Fri Jun 25 10:12:47 PDT 2021
Author: Philip Reames
Date: 2021-06-25T10:09:58-07:00
New Revision: e80a21d632900341258a20134e43ad76a2c93c81
URL: https://github.com/llvm/llvm-project/commit/e80a21d632900341258a20134e43ad76a2c93c81
DIFF: https://github.com/llvm/llvm-project/commit/e80a21d632900341258a20134e43ad76a2c93c81.diff
LOG: [test][instcombine] Add test cases for all x.with.overflow overflow checks
For each of the x.with.overflow variants, if only the overflow bit is consumed, we can generate a direct overflow comparison. This precommits tests for each of the variants and tries to cover interesting cornercases.
Added:
llvm/test/Transforms/InstCombine/saddo.ll
llvm/test/Transforms/InstCombine/smulo.ll
llvm/test/Transforms/InstCombine/ssubo.ll
llvm/test/Transforms/InstCombine/usubo.ll
Modified:
llvm/test/Transforms/InstCombine/umulo.ll
Removed:
################################################################################
diff --git a/llvm/test/Transforms/InstCombine/saddo.ll b/llvm/test/Transforms/InstCombine/saddo.ll
new file mode 100644
index 0000000000000..5a3c8f5844e6a
--- /dev/null
+++ b/llvm/test/Transforms/InstCombine/saddo.ll
@@ -0,0 +1,103 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
+; RUN: opt < %s -instcombine -S | FileCheck %s
+
+declare { i64, i1 } @llvm.sadd.with.overflow.i64(i64, i64)
+declare { i8, i1 } @llvm.sadd.with.overflow.i8(i8, i8)
+
+define i1 @test_generic(i64 %a, i64 %b) {
+; CHECK-LABEL: @test_generic(
+; CHECK-NEXT: [[RES:%.*]] = tail call { i64, i1 } @llvm.sadd.with.overflow.i64(i64 [[A:%.*]], i64 [[B:%.*]])
+; CHECK-NEXT: [[OVERFLOW:%.*]] = extractvalue { i64, i1 } [[RES]], 1
+; CHECK-NEXT: ret i1 [[OVERFLOW]]
+;
+ %res = tail call { i64, i1 } @llvm.sadd.with.overflow.i64(i64 %a, i64 %b)
+ %overflow = extractvalue { i64, i1 } %res, 1
+ ret i1 %overflow
+}
+
+define i1 @test_constant0(i8 %a) {
+; CHECK-LABEL: @test_constant0(
+; CHECK-NEXT: ret i1 false
+;
+ %res = tail call { i8, i1 } @llvm.sadd.with.overflow.i8(i8 %a, i8 0)
+ %overflow = extractvalue { i8, i1 } %res, 1
+ ret i1 %overflow
+}
+
+define i1 @test_constant1(i8 %a) {
+; CHECK-LABEL: @test_constant1(
+; CHECK-NEXT: [[RES:%.*]] = tail call { i8, i1 } @llvm.sadd.with.overflow.i8(i8 [[A:%.*]], i8 1)
+; CHECK-NEXT: [[OVERFLOW:%.*]] = extractvalue { i8, i1 } [[RES]], 1
+; CHECK-NEXT: ret i1 [[OVERFLOW]]
+;
+ %res = tail call { i8, i1 } @llvm.sadd.with.overflow.i8(i8 %a, i8 1)
+ %overflow = extractvalue { i8, i1 } %res, 1
+ ret i1 %overflow
+}
+
+define i1 @test_constant2(i8 %a) {
+; CHECK-LABEL: @test_constant2(
+; CHECK-NEXT: [[RES:%.*]] = tail call { i8, i1 } @llvm.sadd.with.overflow.i8(i8 [[A:%.*]], i8 2)
+; CHECK-NEXT: [[OVERFLOW:%.*]] = extractvalue { i8, i1 } [[RES]], 1
+; CHECK-NEXT: ret i1 [[OVERFLOW]]
+;
+ %res = tail call { i8, i1 } @llvm.sadd.with.overflow.i8(i8 %a, i8 2)
+ %overflow = extractvalue { i8, i1 } %res, 1
+ ret i1 %overflow
+}
+
+define i1 @test_constant3(i8 %a) {
+; CHECK-LABEL: @test_constant3(
+; CHECK-NEXT: [[RES:%.*]] = tail call { i8, i1 } @llvm.sadd.with.overflow.i8(i8 [[A:%.*]], i8 3)
+; CHECK-NEXT: [[OVERFLOW:%.*]] = extractvalue { i8, i1 } [[RES]], 1
+; CHECK-NEXT: ret i1 [[OVERFLOW]]
+;
+ %res = tail call { i8, i1 } @llvm.sadd.with.overflow.i8(i8 %a, i8 3)
+ %overflow = extractvalue { i8, i1 } %res, 1
+ ret i1 %overflow
+}
+
+define i1 @test_constant4(i8 %a) {
+; CHECK-LABEL: @test_constant4(
+; CHECK-NEXT: [[RES:%.*]] = tail call { i8, i1 } @llvm.sadd.with.overflow.i8(i8 [[A:%.*]], i8 4)
+; CHECK-NEXT: [[OVERFLOW:%.*]] = extractvalue { i8, i1 } [[RES]], 1
+; CHECK-NEXT: ret i1 [[OVERFLOW]]
+;
+ %res = tail call { i8, i1 } @llvm.sadd.with.overflow.i8(i8 %a, i8 4)
+ %overflow = extractvalue { i8, i1 } %res, 1
+ ret i1 %overflow
+}
+
+define i1 @test_constant127(i8 %a) {
+; CHECK-LABEL: @test_constant127(
+; CHECK-NEXT: [[RES:%.*]] = tail call { i8, i1 } @llvm.sadd.with.overflow.i8(i8 [[A:%.*]], i8 127)
+; CHECK-NEXT: [[OVERFLOW:%.*]] = extractvalue { i8, i1 } [[RES]], 1
+; CHECK-NEXT: ret i1 [[OVERFLOW]]
+;
+ %res = tail call { i8, i1 } @llvm.sadd.with.overflow.i8(i8 %a, i8 127)
+ %overflow = extractvalue { i8, i1 } %res, 1
+ ret i1 %overflow
+}
+
+define i1 @test_constant128(i8 %a) {
+; CHECK-LABEL: @test_constant128(
+; CHECK-NEXT: [[RES:%.*]] = tail call { i8, i1 } @llvm.sadd.with.overflow.i8(i8 [[A:%.*]], i8 -128)
+; CHECK-NEXT: [[OVERFLOW:%.*]] = extractvalue { i8, i1 } [[RES]], 1
+; CHECK-NEXT: ret i1 [[OVERFLOW]]
+;
+ %res = tail call { i8, i1 } @llvm.sadd.with.overflow.i8(i8 %a, i8 128)
+ %overflow = extractvalue { i8, i1 } %res, 1
+ ret i1 %overflow
+}
+
+define i1 @test_constant255(i8 %a) {
+; CHECK-LABEL: @test_constant255(
+; CHECK-NEXT: [[RES:%.*]] = tail call { i8, i1 } @llvm.sadd.with.overflow.i8(i8 [[A:%.*]], i8 -1)
+; CHECK-NEXT: [[OVERFLOW:%.*]] = extractvalue { i8, i1 } [[RES]], 1
+; CHECK-NEXT: ret i1 [[OVERFLOW]]
+;
+ %res = tail call { i8, i1 } @llvm.sadd.with.overflow.i8(i8 %a, i8 255)
+ %overflow = extractvalue { i8, i1 } %res, 1
+ ret i1 %overflow
+}
+
diff --git a/llvm/test/Transforms/InstCombine/smulo.ll b/llvm/test/Transforms/InstCombine/smulo.ll
new file mode 100644
index 0000000000000..47315202f9527
--- /dev/null
+++ b/llvm/test/Transforms/InstCombine/smulo.ll
@@ -0,0 +1,102 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
+; RUN: opt < %s -instcombine -S | FileCheck %s
+
+declare { i64, i1 } @llvm.smul.with.overflow.i64(i64, i64)
+declare { i8, i1 } @llvm.smul.with.overflow.i8(i8, i8)
+
+define i1 @test_generic(i64 %a, i64 %b) {
+; CHECK-LABEL: @test_generic(
+; CHECK-NEXT: [[RES:%.*]] = tail call { i64, i1 } @llvm.smul.with.overflow.i64(i64 [[A:%.*]], i64 [[B:%.*]])
+; CHECK-NEXT: [[OVERFLOW:%.*]] = extractvalue { i64, i1 } [[RES]], 1
+; CHECK-NEXT: ret i1 [[OVERFLOW]]
+;
+ %res = tail call { i64, i1 } @llvm.smul.with.overflow.i64(i64 %a, i64 %b)
+ %overflow = extractvalue { i64, i1 } %res, 1
+ ret i1 %overflow
+}
+
+define i1 @test_constant0(i8 %a) {
+; CHECK-LABEL: @test_constant0(
+; CHECK-NEXT: ret i1 false
+;
+ %res = tail call { i8, i1 } @llvm.smul.with.overflow.i8(i8 %a, i8 0)
+ %overflow = extractvalue { i8, i1 } %res, 1
+ ret i1 %overflow
+}
+
+define i1 @test_constant1(i8 %a) {
+; CHECK-LABEL: @test_constant1(
+; CHECK-NEXT: ret i1 false
+;
+ %res = tail call { i8, i1 } @llvm.smul.with.overflow.i8(i8 %a, i8 1)
+ %overflow = extractvalue { i8, i1 } %res, 1
+ ret i1 %overflow
+}
+
+define i1 @test_constant2(i8 %a) {
+; CHECK-LABEL: @test_constant2(
+; CHECK-NEXT: [[RES:%.*]] = tail call { i8, i1 } @llvm.smul.with.overflow.i8(i8 [[A:%.*]], i8 2)
+; CHECK-NEXT: [[OVERFLOW:%.*]] = extractvalue { i8, i1 } [[RES]], 1
+; CHECK-NEXT: ret i1 [[OVERFLOW]]
+;
+ %res = tail call { i8, i1 } @llvm.smul.with.overflow.i8(i8 %a, i8 2)
+ %overflow = extractvalue { i8, i1 } %res, 1
+ ret i1 %overflow
+}
+
+define i1 @test_constant3(i8 %a) {
+; CHECK-LABEL: @test_constant3(
+; CHECK-NEXT: [[RES:%.*]] = tail call { i8, i1 } @llvm.smul.with.overflow.i8(i8 [[A:%.*]], i8 3)
+; CHECK-NEXT: [[OVERFLOW:%.*]] = extractvalue { i8, i1 } [[RES]], 1
+; CHECK-NEXT: ret i1 [[OVERFLOW]]
+;
+ %res = tail call { i8, i1 } @llvm.smul.with.overflow.i8(i8 %a, i8 3)
+ %overflow = extractvalue { i8, i1 } %res, 1
+ ret i1 %overflow
+}
+
+define i1 @test_constant4(i8 %a) {
+; CHECK-LABEL: @test_constant4(
+; CHECK-NEXT: [[RES:%.*]] = tail call { i8, i1 } @llvm.smul.with.overflow.i8(i8 [[A:%.*]], i8 4)
+; CHECK-NEXT: [[OVERFLOW:%.*]] = extractvalue { i8, i1 } [[RES]], 1
+; CHECK-NEXT: ret i1 [[OVERFLOW]]
+;
+ %res = tail call { i8, i1 } @llvm.smul.with.overflow.i8(i8 %a, i8 4)
+ %overflow = extractvalue { i8, i1 } %res, 1
+ ret i1 %overflow
+}
+
+
+define i1 @test_constant127(i8 %a) {
+; CHECK-LABEL: @test_constant127(
+; CHECK-NEXT: [[RES:%.*]] = tail call { i8, i1 } @llvm.smul.with.overflow.i8(i8 [[A:%.*]], i8 127)
+; CHECK-NEXT: [[OVERFLOW:%.*]] = extractvalue { i8, i1 } [[RES]], 1
+; CHECK-NEXT: ret i1 [[OVERFLOW]]
+;
+ %res = tail call { i8, i1 } @llvm.smul.with.overflow.i8(i8 %a, i8 127)
+ %overflow = extractvalue { i8, i1 } %res, 1
+ ret i1 %overflow
+}
+
+define i1 @test_constant128(i8 %a) {
+; CHECK-LABEL: @test_constant128(
+; CHECK-NEXT: [[RES:%.*]] = tail call { i8, i1 } @llvm.smul.with.overflow.i8(i8 [[A:%.*]], i8 -128)
+; CHECK-NEXT: [[OVERFLOW:%.*]] = extractvalue { i8, i1 } [[RES]], 1
+; CHECK-NEXT: ret i1 [[OVERFLOW]]
+;
+ %res = tail call { i8, i1 } @llvm.smul.with.overflow.i8(i8 %a, i8 128)
+ %overflow = extractvalue { i8, i1 } %res, 1
+ ret i1 %overflow
+}
+
+define i1 @test_constant255(i8 %a) {
+; CHECK-LABEL: @test_constant255(
+; CHECK-NEXT: [[RES:%.*]] = tail call { i8, i1 } @llvm.smul.with.overflow.i8(i8 [[A:%.*]], i8 -1)
+; CHECK-NEXT: [[OVERFLOW:%.*]] = extractvalue { i8, i1 } [[RES]], 1
+; CHECK-NEXT: ret i1 [[OVERFLOW]]
+;
+ %res = tail call { i8, i1 } @llvm.smul.with.overflow.i8(i8 %a, i8 255)
+ %overflow = extractvalue { i8, i1 } %res, 1
+ ret i1 %overflow
+}
+
diff --git a/llvm/test/Transforms/InstCombine/ssubo.ll b/llvm/test/Transforms/InstCombine/ssubo.ll
new file mode 100644
index 0000000000000..9b11f6ac145fd
--- /dev/null
+++ b/llvm/test/Transforms/InstCombine/ssubo.ll
@@ -0,0 +1,104 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
+; RUN: opt < %s -instcombine -S | FileCheck %s
+
+declare { i64, i1 } @llvm.ssub.with.overflow.i64(i64, i64)
+declare { i8, i1 } @llvm.ssub.with.overflow.i8(i8, i8)
+
+define i1 @test_generic(i64 %a, i64 %b) {
+; CHECK-LABEL: @test_generic(
+; CHECK-NEXT: [[RES:%.*]] = tail call { i64, i1 } @llvm.ssub.with.overflow.i64(i64 [[A:%.*]], i64 [[B:%.*]])
+; CHECK-NEXT: [[OVERFLOW:%.*]] = extractvalue { i64, i1 } [[RES]], 1
+; CHECK-NEXT: ret i1 [[OVERFLOW]]
+;
+ %res = tail call { i64, i1 } @llvm.ssub.with.overflow.i64(i64 %a, i64 %b)
+ %overflow = extractvalue { i64, i1 } %res, 1
+ ret i1 %overflow
+}
+
+define i1 @test_constant0(i8 %a) {
+; CHECK-LABEL: @test_constant0(
+; CHECK-NEXT: ret i1 false
+;
+ %res = tail call { i8, i1 } @llvm.ssub.with.overflow.i8(i8 %a, i8 0)
+ %overflow = extractvalue { i8, i1 } %res, 1
+ ret i1 %overflow
+}
+
+define i1 @test_constant1(i8 %a) {
+; CHECK-LABEL: @test_constant1(
+; CHECK-NEXT: [[TMP1:%.*]] = call { i8, i1 } @llvm.sadd.with.overflow.i8(i8 [[A:%.*]], i8 -1)
+; CHECK-NEXT: [[OVERFLOW:%.*]] = extractvalue { i8, i1 } [[TMP1]], 1
+; CHECK-NEXT: ret i1 [[OVERFLOW]]
+;
+ %res = tail call { i8, i1 } @llvm.ssub.with.overflow.i8(i8 %a, i8 1)
+ %overflow = extractvalue { i8, i1 } %res, 1
+ ret i1 %overflow
+}
+
+define i1 @test_constant2(i8 %a) {
+; CHECK-LABEL: @test_constant2(
+; CHECK-NEXT: [[TMP1:%.*]] = call { i8, i1 } @llvm.sadd.with.overflow.i8(i8 [[A:%.*]], i8 -2)
+; CHECK-NEXT: [[OVERFLOW:%.*]] = extractvalue { i8, i1 } [[TMP1]], 1
+; CHECK-NEXT: ret i1 [[OVERFLOW]]
+;
+ %res = tail call { i8, i1 } @llvm.ssub.with.overflow.i8(i8 %a, i8 2)
+ %overflow = extractvalue { i8, i1 } %res, 1
+ ret i1 %overflow
+}
+
+define i1 @test_constant3(i8 %a) {
+; CHECK-LABEL: @test_constant3(
+; CHECK-NEXT: [[TMP1:%.*]] = call { i8, i1 } @llvm.sadd.with.overflow.i8(i8 [[A:%.*]], i8 -3)
+; CHECK-NEXT: [[OVERFLOW:%.*]] = extractvalue { i8, i1 } [[TMP1]], 1
+; CHECK-NEXT: ret i1 [[OVERFLOW]]
+;
+ %res = tail call { i8, i1 } @llvm.ssub.with.overflow.i8(i8 %a, i8 3)
+ %overflow = extractvalue { i8, i1 } %res, 1
+ ret i1 %overflow
+}
+
+define i1 @test_constant4(i8 %a) {
+; CHECK-LABEL: @test_constant4(
+; CHECK-NEXT: [[TMP1:%.*]] = call { i8, i1 } @llvm.sadd.with.overflow.i8(i8 [[A:%.*]], i8 -4)
+; CHECK-NEXT: [[OVERFLOW:%.*]] = extractvalue { i8, i1 } [[TMP1]], 1
+; CHECK-NEXT: ret i1 [[OVERFLOW]]
+;
+ %res = tail call { i8, i1 } @llvm.ssub.with.overflow.i8(i8 %a, i8 4)
+ %overflow = extractvalue { i8, i1 } %res, 1
+ ret i1 %overflow
+}
+
+
+define i1 @test_constant127(i8 %a) {
+; CHECK-LABEL: @test_constant127(
+; CHECK-NEXT: [[TMP1:%.*]] = call { i8, i1 } @llvm.sadd.with.overflow.i8(i8 [[A:%.*]], i8 -127)
+; CHECK-NEXT: [[OVERFLOW:%.*]] = extractvalue { i8, i1 } [[TMP1]], 1
+; CHECK-NEXT: ret i1 [[OVERFLOW]]
+;
+ %res = tail call { i8, i1 } @llvm.ssub.with.overflow.i8(i8 %a, i8 127)
+ %overflow = extractvalue { i8, i1 } %res, 1
+ ret i1 %overflow
+}
+
+define i1 @test_constant128(i8 %a) {
+; CHECK-LABEL: @test_constant128(
+; CHECK-NEXT: [[RES:%.*]] = tail call { i8, i1 } @llvm.ssub.with.overflow.i8(i8 [[A:%.*]], i8 -128)
+; CHECK-NEXT: [[OVERFLOW:%.*]] = extractvalue { i8, i1 } [[RES]], 1
+; CHECK-NEXT: ret i1 [[OVERFLOW]]
+;
+ %res = tail call { i8, i1 } @llvm.ssub.with.overflow.i8(i8 %a, i8 128)
+ %overflow = extractvalue { i8, i1 } %res, 1
+ ret i1 %overflow
+}
+
+define i1 @test_constant255(i8 %a) {
+; CHECK-LABEL: @test_constant255(
+; CHECK-NEXT: [[TMP1:%.*]] = call { i8, i1 } @llvm.sadd.with.overflow.i8(i8 [[A:%.*]], i8 1)
+; CHECK-NEXT: [[OVERFLOW:%.*]] = extractvalue { i8, i1 } [[TMP1]], 1
+; CHECK-NEXT: ret i1 [[OVERFLOW]]
+;
+ %res = tail call { i8, i1 } @llvm.ssub.with.overflow.i8(i8 %a, i8 255)
+ %overflow = extractvalue { i8, i1 } %res, 1
+ ret i1 %overflow
+}
+
diff --git a/llvm/test/Transforms/InstCombine/umulo.ll b/llvm/test/Transforms/InstCombine/umulo.ll
index c854b8377cabf..cce455e842881 100644
--- a/llvm/test/Transforms/InstCombine/umulo.ll
+++ b/llvm/test/Transforms/InstCombine/umulo.ll
@@ -55,6 +55,18 @@ define i1 @test_constant3(i8 %a) {
ret i1 %overflow
}
+define i1 @test_constant4(i8 %a) {
+; CHECK-LABEL: @test_constant4(
+; CHECK-NEXT: [[RES:%.*]] = tail call { i8, i1 } @llvm.umul.with.overflow.i8(i8 [[A:%.*]], i8 4)
+; CHECK-NEXT: [[OVERFLOW:%.*]] = extractvalue { i8, i1 } [[RES]], 1
+; CHECK-NEXT: ret i1 [[OVERFLOW]]
+;
+ %res = tail call { i8, i1 } @llvm.umul.with.overflow.i8(i8 %a, i8 4)
+ %overflow = extractvalue { i8, i1 } %res, 1
+ ret i1 %overflow
+}
+
+
define i1 @test_constant127(i8 %a) {
; CHECK-LABEL: @test_constant127(
; CHECK-NEXT: [[RES:%.*]] = tail call { i8, i1 } @llvm.umul.with.overflow.i8(i8 [[A:%.*]], i8 127)
diff --git a/llvm/test/Transforms/InstCombine/usubo.ll b/llvm/test/Transforms/InstCombine/usubo.ll
new file mode 100644
index 0000000000000..26f8cd2421d77
--- /dev/null
+++ b/llvm/test/Transforms/InstCombine/usubo.ll
@@ -0,0 +1,104 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
+; RUN: opt < %s -instcombine -S | FileCheck %s
+
+declare { i64, i1 } @llvm.usub.with.overflow.i64(i64, i64)
+declare { i8, i1 } @llvm.usub.with.overflow.i8(i8, i8)
+
+define i1 @test_generic(i64 %a, i64 %b) {
+; CHECK-LABEL: @test_generic(
+; CHECK-NEXT: [[RES:%.*]] = tail call { i64, i1 } @llvm.usub.with.overflow.i64(i64 [[A:%.*]], i64 [[B:%.*]])
+; CHECK-NEXT: [[OVERFLOW:%.*]] = extractvalue { i64, i1 } [[RES]], 1
+; CHECK-NEXT: ret i1 [[OVERFLOW]]
+;
+ %res = tail call { i64, i1 } @llvm.usub.with.overflow.i64(i64 %a, i64 %b)
+ %overflow = extractvalue { i64, i1 } %res, 1
+ ret i1 %overflow
+}
+
+define i1 @test_constant0(i8 %a) {
+; CHECK-LABEL: @test_constant0(
+; CHECK-NEXT: ret i1 false
+;
+ %res = tail call { i8, i1 } @llvm.usub.with.overflow.i8(i8 %a, i8 0)
+ %overflow = extractvalue { i8, i1 } %res, 1
+ ret i1 %overflow
+}
+
+define i1 @test_constant1(i8 %a) {
+; CHECK-LABEL: @test_constant1(
+; CHECK-NEXT: [[RES:%.*]] = tail call { i8, i1 } @llvm.usub.with.overflow.i8(i8 [[A:%.*]], i8 1)
+; CHECK-NEXT: [[OVERFLOW:%.*]] = extractvalue { i8, i1 } [[RES]], 1
+; CHECK-NEXT: ret i1 [[OVERFLOW]]
+;
+ %res = tail call { i8, i1 } @llvm.usub.with.overflow.i8(i8 %a, i8 1)
+ %overflow = extractvalue { i8, i1 } %res, 1
+ ret i1 %overflow
+}
+
+define i1 @test_constant2(i8 %a) {
+; CHECK-LABEL: @test_constant2(
+; CHECK-NEXT: [[RES:%.*]] = tail call { i8, i1 } @llvm.usub.with.overflow.i8(i8 [[A:%.*]], i8 2)
+; CHECK-NEXT: [[OVERFLOW:%.*]] = extractvalue { i8, i1 } [[RES]], 1
+; CHECK-NEXT: ret i1 [[OVERFLOW]]
+;
+ %res = tail call { i8, i1 } @llvm.usub.with.overflow.i8(i8 %a, i8 2)
+ %overflow = extractvalue { i8, i1 } %res, 1
+ ret i1 %overflow
+}
+
+define i1 @test_constant3(i8 %a) {
+; CHECK-LABEL: @test_constant3(
+; CHECK-NEXT: [[RES:%.*]] = tail call { i8, i1 } @llvm.usub.with.overflow.i8(i8 [[A:%.*]], i8 3)
+; CHECK-NEXT: [[OVERFLOW:%.*]] = extractvalue { i8, i1 } [[RES]], 1
+; CHECK-NEXT: ret i1 [[OVERFLOW]]
+;
+ %res = tail call { i8, i1 } @llvm.usub.with.overflow.i8(i8 %a, i8 3)
+ %overflow = extractvalue { i8, i1 } %res, 1
+ ret i1 %overflow
+}
+
+define i1 @test_constant4(i8 %a) {
+; CHECK-LABEL: @test_constant4(
+; CHECK-NEXT: [[RES:%.*]] = tail call { i8, i1 } @llvm.usub.with.overflow.i8(i8 [[A:%.*]], i8 4)
+; CHECK-NEXT: [[OVERFLOW:%.*]] = extractvalue { i8, i1 } [[RES]], 1
+; CHECK-NEXT: ret i1 [[OVERFLOW]]
+;
+ %res = tail call { i8, i1 } @llvm.usub.with.overflow.i8(i8 %a, i8 4)
+ %overflow = extractvalue { i8, i1 } %res, 1
+ ret i1 %overflow
+}
+
+
+define i1 @test_constant127(i8 %a) {
+; CHECK-LABEL: @test_constant127(
+; CHECK-NEXT: [[RES:%.*]] = tail call { i8, i1 } @llvm.usub.with.overflow.i8(i8 [[A:%.*]], i8 127)
+; CHECK-NEXT: [[OVERFLOW:%.*]] = extractvalue { i8, i1 } [[RES]], 1
+; CHECK-NEXT: ret i1 [[OVERFLOW]]
+;
+ %res = tail call { i8, i1 } @llvm.usub.with.overflow.i8(i8 %a, i8 127)
+ %overflow = extractvalue { i8, i1 } %res, 1
+ ret i1 %overflow
+}
+
+define i1 @test_constant128(i8 %a) {
+; CHECK-LABEL: @test_constant128(
+; CHECK-NEXT: [[RES:%.*]] = tail call { i8, i1 } @llvm.usub.with.overflow.i8(i8 [[A:%.*]], i8 -128)
+; CHECK-NEXT: [[OVERFLOW:%.*]] = extractvalue { i8, i1 } [[RES]], 1
+; CHECK-NEXT: ret i1 [[OVERFLOW]]
+;
+ %res = tail call { i8, i1 } @llvm.usub.with.overflow.i8(i8 %a, i8 128)
+ %overflow = extractvalue { i8, i1 } %res, 1
+ ret i1 %overflow
+}
+
+define i1 @test_constant255(i8 %a) {
+; CHECK-LABEL: @test_constant255(
+; CHECK-NEXT: [[RES:%.*]] = tail call { i8, i1 } @llvm.usub.with.overflow.i8(i8 [[A:%.*]], i8 -1)
+; CHECK-NEXT: [[OVERFLOW:%.*]] = extractvalue { i8, i1 } [[RES]], 1
+; CHECK-NEXT: ret i1 [[OVERFLOW]]
+;
+ %res = tail call { i8, i1 } @llvm.usub.with.overflow.i8(i8 %a, i8 255)
+ %overflow = extractvalue { i8, i1 } %res, 1
+ ret i1 %overflow
+}
+
More information about the llvm-commits
mailing list