[llvm] d0b4ed9 - [ValueTracking] Add tests for knowing `sdiv` is non-zero; NFC
Noah Goldstein via llvm-commits
llvm-commits at lists.llvm.org
Thu Aug 24 17:43:27 PDT 2023
Author: Noah Goldstein
Date: 2023-08-24T19:43:10-05:00
New Revision: d0b4ed9a2cf353eb9f59be344862595af2bd205d
URL: https://github.com/llvm/llvm-project/commit/d0b4ed9a2cf353eb9f59be344862595af2bd205d
DIFF: https://github.com/llvm/llvm-project/commit/d0b4ed9a2cf353eb9f59be344862595af2bd205d.diff
LOG: [ValueTracking] Add tests for knowing `sdiv` is non-zero; NFC
Differential Revision: https://reviews.llvm.org/D157301
Added:
Modified:
llvm/test/Analysis/ValueTracking/known-non-zero.ll
Removed:
################################################################################
diff --git a/llvm/test/Analysis/ValueTracking/known-non-zero.ll b/llvm/test/Analysis/ValueTracking/known-non-zero.ll
index cc77caa29f6996..44b825f64ce951 100644
--- a/llvm/test/Analysis/ValueTracking/known-non-zero.ll
+++ b/llvm/test/Analysis/ValueTracking/known-non-zero.ll
@@ -1122,3 +1122,50 @@ define i1 @src_mul_maybe_zero_no_nonzero_mul(i8 %x, i8 %y) {
%nz = icmp ne i8 %xy, 0
ret i1 %nz
}
+
+define i1 @sdiv_known_non_zero(i8 %x, i8 %y) {
+; CHECK-LABEL: @sdiv_known_non_zero(
+; CHECK-NEXT: [[XX0:%.*]] = or i8 [[X:%.*]], -121
+; CHECK-NEXT: [[XX:%.*]] = and i8 [[XX0]], -2
+; CHECK-NEXT: [[XY:%.*]] = sdiv i8 [[XX]], -2
+; CHECK-NEXT: [[NZ:%.*]] = icmp ne i8 [[XY]], 0
+; CHECK-NEXT: ret i1 [[NZ]]
+;
+ %xx0 = or i8 %x, 135
+ %xx = and i8 %xx0, -2
+ %xy = sdiv i8 %xx, -2
+ %nz = icmp ne i8 %xy, 0
+ ret i1 %nz
+}
+
+define i1 @sdiv_known_non_zero2(i8 %x, i8 %y) {
+; CHECK-LABEL: @sdiv_known_non_zero2(
+; CHECK-NEXT: [[XX0:%.*]] = or i8 [[X:%.*]], 15
+; CHECK-NEXT: [[XX:%.*]] = and i8 [[XX0]], -4
+; CHECK-NEXT: [[YY:%.*]] = and i8 [[Y:%.*]], 3
+; CHECK-NEXT: [[XY:%.*]] = sdiv i8 [[XX]], [[YY]]
+; CHECK-NEXT: [[NZ:%.*]] = icmp ne i8 [[XY]], 0
+; CHECK-NEXT: ret i1 [[NZ]]
+;
+ %xx0 = or i8 %x, 15
+ %xx = and i8 %xx0, -4
+ %yy = and i8 %y, 3
+ %xy = sdiv i8 %xx, %yy
+ %nz = icmp ne i8 %xy, 0
+ ret i1 %nz
+}
+
+define i1 @sdiv_known_non_zero_fail(i8 %x, i8 %y) {
+; CHECK-LABEL: @sdiv_known_non_zero_fail(
+; CHECK-NEXT: [[XX:%.*]] = or i8 [[X:%.*]], 15
+; CHECK-NEXT: [[YY:%.*]] = and i8 [[Y:%.*]], 3
+; CHECK-NEXT: [[XY:%.*]] = sdiv i8 [[XX]], [[YY]]
+; CHECK-NEXT: [[NZ:%.*]] = icmp ne i8 [[XY]], 0
+; CHECK-NEXT: ret i1 [[NZ]]
+;
+ %xx = or i8 %x, 15
+ %yy = and i8 %y, 3
+ %xy = sdiv i8 %xx, %yy
+ %nz = icmp ne i8 %xy, 0
+ ret i1 %nz
+}
More information about the llvm-commits
mailing list