[PATCH] D157301: [ValueTracking] Add tests for knowing `sdiv` is non-zero; NFC

Noah Goldstein via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Aug 24 10:47:33 PDT 2023


goldstein.w.n updated this revision to Diff 553189.
goldstein.w.n added a comment.

Fixup comment/early return


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D157301/new/

https://reviews.llvm.org/D157301

Files:
  llvm/test/Analysis/ValueTracking/known-non-zero.ll


Index: llvm/test/Analysis/ValueTracking/known-non-zero.ll
===================================================================
--- llvm/test/Analysis/ValueTracking/known-non-zero.ll
+++ llvm/test/Analysis/ValueTracking/known-non-zero.ll
@@ -1122,3 +1122,50 @@
   %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
+}


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D157301.553189.patch
Type: text/x-patch
Size: 1729 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230824/5a6e6c87/attachment.bin>


More information about the llvm-commits mailing list