[llvm] 1911843 - [ConstraintElimination] Add extra tests for different overflows.
Florian Hahn via llvm-commits
llvm-commits at lists.llvm.org
Wed May 11 13:21:17 PDT 2022
Author: Florian Hahn
Date: 2022-05-11T21:20:42+01:00
New Revision: 1911843c3126a3cbe13a7fd75146f3fa3e06e133
URL: https://github.com/llvm/llvm-project/commit/1911843c3126a3cbe13a7fd75146f3fa3e06e133
DIFF: https://github.com/llvm/llvm-project/commit/1911843c3126a3cbe13a7fd75146f3fa3e06e133.diff
LOG: [ConstraintElimination] Add extra tests for different overflows.
Additional tests for D125264, inspired by @spatel.
Added:
Modified:
llvm/test/Transforms/ConstraintElimination/ssub-with-overflow.ll
Removed:
################################################################################
diff --git a/llvm/test/Transforms/ConstraintElimination/ssub-with-overflow.ll b/llvm/test/Transforms/ConstraintElimination/ssub-with-overflow.ll
index 29d631591a0fd..aa1a63aefde00 100644
--- a/llvm/test/Transforms/ConstraintElimination/ssub-with-overflow.ll
+++ b/llvm/test/Transforms/ConstraintElimination/ssub-with-overflow.ll
@@ -284,3 +284,75 @@ exit.ok:
exit.fail:
ret i8 0
}
+
+define i8 @ssub_may_overflow5(i8 %a, i8 %b) {
+; CHECK-LABEL: @ssub_may_overflow5(
+; CHECK-NEXT: entry:
+; CHECK-NEXT: [[C_1:%.*]] = icmp sge i8 [[B:%.*]], [[A:%.*]]
+; CHECK-NEXT: [[C_2:%.*]] = icmp sge i8 [[B]], 0
+; CHECK-NEXT: [[AND:%.*]] = and i1 [[C_2]], [[C_1]]
+; CHECK-NEXT: br i1 [[AND]], label [[MATH:%.*]], label [[EXIT_FAIL:%.*]]
+; CHECK: math:
+; CHECK-NEXT: [[OP:%.*]] = tail call { i8, i1 } @llvm.ssub.with.overflow.i8(i8 [[B]], i8 [[A]])
+; CHECK-NEXT: [[STATUS:%.*]] = extractvalue { i8, i1 } [[OP]], 1
+; CHECK-NEXT: br i1 [[STATUS]], label [[EXIT_FAIL]], label [[EXIT_OK:%.*]]
+; CHECK: exit.ok:
+; CHECK-NEXT: [[RES:%.*]] = extractvalue { i8, i1 } [[OP]], 0
+; CHECK-NEXT: ret i8 [[RES]]
+; CHECK: exit.fail:
+; CHECK-NEXT: ret i8 0
+;
+entry:
+ %c.1 = icmp sge i8 %b, %a
+ %c.2 = icmp sge i8 %b, 0
+ %and = and i1 %c.2, %c.1
+ br i1 %and, label %math, label %exit.fail
+
+math:
+ %op = tail call { i8, i1 } @llvm.ssub.with.overflow.i8(i8 %b, i8 %a)
+ %status = extractvalue { i8, i1 } %op, 1
+ br i1 %status, label %exit.fail, label %exit.ok
+
+exit.ok:
+ %res = extractvalue { i8, i1 } %op, 0
+ ret i8 %res
+
+exit.fail:
+ ret i8 0
+}
+
+define i8 @ssub_may_overflow6(i8 %a, i8 %b) {
+; CHECK-LABEL: @ssub_may_overflow6(
+; CHECK-NEXT: entry:
+; CHECK-NEXT: [[C_1:%.*]] = icmp sle i8 [[B:%.*]], [[A:%.*]]
+; CHECK-NEXT: [[C_2:%.*]] = icmp slt i8 [[B]], 0
+; CHECK-NEXT: [[OR_COND:%.*]] = or i1 [[C_2]], [[C_1]]
+; CHECK-NEXT: br i1 [[OR_COND]], label [[EXIT_FAIL:%.*]], label [[MATH:%.*]]
+; CHECK: math:
+; CHECK-NEXT: [[OP:%.*]] = tail call { i8, i1 } @llvm.ssub.with.overflow.i8(i8 [[B]], i8 [[A]])
+; CHECK-NEXT: [[STATUS:%.*]] = extractvalue { i8, i1 } [[OP]], 1
+; CHECK-NEXT: br i1 [[STATUS]], label [[EXIT_FAIL]], label [[EXIT_OK:%.*]]
+; CHECK: exit.ok:
+; CHECK-NEXT: [[RES:%.*]] = extractvalue { i8, i1 } [[OP]], 0
+; CHECK-NEXT: ret i8 [[RES]]
+; CHECK: exit.fail:
+; CHECK-NEXT: ret i8 0
+;
+entry:
+ %c.1 = icmp sle i8 %b, %a
+ %c.2 = icmp slt i8 %b, 0
+ %or.cond = or i1 %c.2, %c.1
+ br i1 %or.cond, label %exit.fail, label %math
+
+math:
+ %op = tail call { i8, i1 } @llvm.ssub.with.overflow.i8(i8 %b, i8 %a)
+ %status = extractvalue { i8, i1 } %op, 1
+ br i1 %status, label %exit.fail, label %exit.ok
+
+exit.ok:
+ %res = extractvalue { i8, i1 } %op, 0
+ ret i8 %res
+
+exit.fail:
+ ret i8 0
+}
More information about the llvm-commits
mailing list