[llvm] aa7076f - [ValueTracking] Add tests for constant range of `{s|u}rem C, x`; NFC
Noah Goldstein via llvm-commits
llvm-commits at lists.llvm.org
Tue Feb 20 08:39:57 PST 2024
Author: Noah Goldstein
Date: 2024-02-20T10:39:33-06:00
New Revision: aa7076fc9b7d4b92fc71637bfdb7cb268bcd53bc
URL: https://github.com/llvm/llvm-project/commit/aa7076fc9b7d4b92fc71637bfdb7cb268bcd53bc
DIFF: https://github.com/llvm/llvm-project/commit/aa7076fc9b7d4b92fc71637bfdb7cb268bcd53bc.diff
LOG: [ValueTracking] Add tests for constant range of `{s|u}rem C, x`; NFC
Added:
Modified:
llvm/test/Analysis/ValueTracking/constant-ranges.ll
Removed:
################################################################################
diff --git a/llvm/test/Analysis/ValueTracking/constant-ranges.ll b/llvm/test/Analysis/ValueTracking/constant-ranges.ll
index 26e01efedd3dfc..addfe0fc4c54d6 100644
--- a/llvm/test/Analysis/ValueTracking/constant-ranges.ll
+++ b/llvm/test/Analysis/ValueTracking/constant-ranges.ll
@@ -130,3 +130,113 @@ define i1 @and_ugt_fail(i8 %xx) {
%r = icmp ugt i8 %x_p2, 127
ret i1 %r
}
+
+define i1 @urem_okay(i8 %x) {
+; CHECK-LABEL: @urem_okay(
+; CHECK-NEXT: [[VAL:%.*]] = urem i8 34, [[X:%.*]]
+; CHECK-NEXT: [[R:%.*]] = icmp ule i8 [[VAL]], 35
+; CHECK-NEXT: ret i1 [[R]]
+;
+ %val = urem i8 34, %x
+ %r = icmp ule i8 %val, 35
+ ret i1 %r
+}
+
+define i1 @urem_fail(i8 %x) {
+; CHECK-LABEL: @urem_fail(
+; CHECK-NEXT: [[VAL:%.*]] = urem i8 34, [[X:%.*]]
+; CHECK-NEXT: [[R:%.*]] = icmp ule i8 [[VAL]], 33
+; CHECK-NEXT: ret i1 [[R]]
+;
+ %val = urem i8 34, %x
+ %r = icmp ule i8 %val, 33
+ ret i1 %r
+}
+
+define i1 @srem_posC_okay0(i8 %x) {
+; CHECK-LABEL: @srem_posC_okay0(
+; CHECK-NEXT: [[VAL:%.*]] = srem i8 34, [[X:%.*]]
+; CHECK-NEXT: [[R:%.*]] = icmp sle i8 [[VAL]], 34
+; CHECK-NEXT: ret i1 [[R]]
+;
+ %val = srem i8 34, %x
+ %r = icmp sle i8 %val, 34
+ ret i1 %r
+}
+
+define i1 @srem_posC_okay1(i8 %x) {
+; CHECK-LABEL: @srem_posC_okay1(
+; CHECK-NEXT: [[VAL:%.*]] = srem i8 34, [[X:%.*]]
+; CHECK-NEXT: [[R:%.*]] = icmp sge i8 [[VAL]], -3
+; CHECK-NEXT: ret i1 [[R]]
+;
+ %val = srem i8 34, %x
+ %r = icmp sge i8 %val, -3
+ ret i1 %r
+}
+
+define i1 @srem_negC_okay0(i8 %x) {
+; CHECK-LABEL: @srem_negC_okay0(
+; CHECK-NEXT: [[VAL:%.*]] = srem i8 -34, [[X:%.*]]
+; CHECK-NEXT: [[R:%.*]] = icmp sle i8 [[VAL]], 0
+; CHECK-NEXT: ret i1 [[R]]
+;
+ %val = srem i8 -34, %x
+ %r = icmp sle i8 %val, 0
+ ret i1 %r
+}
+
+define i1 @srem_negC_okay1(i8 %x) {
+; CHECK-LABEL: @srem_negC_okay1(
+; CHECK-NEXT: [[VAL:%.*]] = srem i8 -34, [[X:%.*]]
+; CHECK-NEXT: [[R:%.*]] = icmp sge i8 [[VAL]], -34
+; CHECK-NEXT: ret i1 [[R]]
+;
+ %val = srem i8 -34, %x
+ %r = icmp sge i8 %val, -34
+ ret i1 %r
+}
+
+define i1 @srem_posC_fail0(i8 %x) {
+; CHECK-LABEL: @srem_posC_fail0(
+; CHECK-NEXT: [[VAL:%.*]] = srem i8 34, [[X:%.*]]
+; CHECK-NEXT: [[R:%.*]] = icmp sle i8 [[VAL]], 32
+; CHECK-NEXT: ret i1 [[R]]
+;
+ %val = srem i8 34, %x
+ %r = icmp sle i8 %val, 32
+ ret i1 %r
+}
+
+define i1 @srem_posC_fail1(i8 %x) {
+; CHECK-LABEL: @srem_posC_fail1(
+; CHECK-NEXT: [[VAL:%.*]] = srem i8 34, [[X:%.*]]
+; CHECK-NEXT: [[R:%.*]] = icmp sge i8 [[VAL]], 1
+; CHECK-NEXT: ret i1 [[R]]
+;
+ %val = srem i8 34, %x
+ %r = icmp sge i8 %val, 1
+ ret i1 %r
+}
+
+define i1 @srem_negC_fail0(i8 %x) {
+; CHECK-LABEL: @srem_negC_fail0(
+; CHECK-NEXT: [[VAL:%.*]] = srem i8 -34, [[X:%.*]]
+; CHECK-NEXT: [[R:%.*]] = icmp sle i8 [[VAL]], -1
+; CHECK-NEXT: ret i1 [[R]]
+;
+ %val = srem i8 -34, %x
+ %r = icmp sle i8 %val, -1
+ ret i1 %r
+}
+
+define i1 @srem_negC_fail1(i8 %x) {
+; CHECK-LABEL: @srem_negC_fail1(
+; CHECK-NEXT: [[VAL:%.*]] = srem i8 -34, [[X:%.*]]
+; CHECK-NEXT: [[R:%.*]] = icmp sge i8 [[VAL]], -33
+; CHECK-NEXT: ret i1 [[R]]
+;
+ %val = srem i8 -34, %x
+ %r = icmp sge i8 %val, -33
+ ret i1 %r
+}
More information about the llvm-commits
mailing list