[llvm] 301fe08 - [ConstraintElimination] Add test where ssub result is not used.
Florian Hahn via llvm-commits
llvm-commits at lists.llvm.org
Wed May 11 08:10:36 PDT 2022
Author: Florian Hahn
Date: 2022-05-11T16:10:25+01:00
New Revision: 301fe084bff388a734d284cf4db9cb44f29d99c0
URL: https://github.com/llvm/llvm-project/commit/301fe084bff388a734d284cf4db9cb44f29d99c0
DIFF: https://github.com/llvm/llvm-project/commit/301fe084bff388a734d284cf4db9cb44f29d99c0.diff
LOG: [ConstraintElimination] Add test where ssub result is not used.
Extra tests for D125264.
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 05eb713ea9623..29d631591a0fd 100644
--- a/llvm/test/Transforms/ConstraintElimination/ssub-with-overflow.ll
+++ b/llvm/test/Transforms/ConstraintElimination/ssub-with-overflow.ll
@@ -39,6 +39,46 @@ exit.fail:
ret i8 0
}
+declare void @use_res({ i8, i1 })
+
+define i8 @ssub_no_overflow_due_to_or_conds_result_used(i8 %a, i8 %b) {
+; CHECK-LABEL: @ssub_no_overflow_due_to_or_conds_result_used(
+; CHECK-NEXT: entry:
+; CHECK-NEXT: [[C_1:%.*]] = icmp sle i8 [[B:%.*]], [[A:%.*]]
+; CHECK-NEXT: [[C_2:%.*]] = icmp slt i8 [[A]], 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: call void @use_res({ i8, i1 } [[OP]])
+; 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 %a, 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)
+ call void @use_res({ i8, i1 } %op)
+ %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_no_overflow_due_to_and_conds(i8 %a, i8 %b) {
; CHECK-LABEL: @ssub_no_overflow_due_to_and_conds(
; CHECK-NEXT: entry:
@@ -75,6 +115,40 @@ exit.fail:
ret i8 0
}
+define i8 @ssub_no_overflow_due_to_and_conds_sub_result_not_used(i8 %a, i8 %b) {
+; CHECK-LABEL: @ssub_no_overflow_due_to_and_conds_sub_result_not_used(
+; CHECK-NEXT: entry:
+; CHECK-NEXT: [[C_1:%.*]] = icmp sge i8 [[B:%.*]], [[A:%.*]]
+; CHECK-NEXT: [[C_2:%.*]] = icmp sge i8 [[A]], 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: ret i8 20
+; CHECK: exit.fail:
+; CHECK-NEXT: ret i8 0
+;
+entry:
+ %c.1 = icmp sge i8 %b, %a
+ %c.2 = icmp sge i8 %a, 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:
+ ret i8 20
+
+exit.fail:
+ ret i8 0
+}
+
define i8 @ssub_may_overflow1(i8 %a, i8 %b) {
; CHECK-LABEL: @ssub_may_overflow1(
; CHECK-NEXT: entry:
More information about the llvm-commits
mailing list