[PATCH] D150922: [KnownBits] Return `0` for poison {s,u}div inputs
Noah Goldstein via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Sun May 28 14:19:44 PDT 2023
goldstein.w.n updated this revision to Diff 526345.
goldstein.w.n added a comment.
Remove cases that don't help cleanup rest of the code
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D150922/new/
https://reviews.llvm.org/D150922
Files:
llvm/lib/Support/KnownBits.cpp
llvm/test/CodeGen/WebAssembly/pr59626.ll
Index: llvm/test/CodeGen/WebAssembly/pr59626.ll
===================================================================
--- llvm/test/CodeGen/WebAssembly/pr59626.ll
+++ llvm/test/CodeGen/WebAssembly/pr59626.ll
@@ -13,6 +13,9 @@
; CHECK-32-NEXT: i32.const 0
; CHECK-32-NEXT: i32.store16 0
; CHECK-32-NEXT: local.get 1
+; CHECK-32-NEXT: i32.const 0
+; CHECK-32-NEXT: i32.store8 2
+; CHECK-32-NEXT: local.get 1
; CHECK-32-NEXT: local.get 0
; CHECK-32-NEXT: i8x16.splat
; CHECK-32-NEXT: v128.store16_lane 0, 0
Index: llvm/lib/Support/KnownBits.cpp
===================================================================
--- llvm/lib/Support/KnownBits.cpp
+++ llvm/lib/Support/KnownBits.cpp
@@ -750,6 +750,13 @@
assert(!LHS.hasConflict() && !RHS.hasConflict() && "Bad inputs");
KnownBits Known(BitWidth);
+ if (LHS.isZero() || RHS.isZero()) {
+ // Result is either known Zero or Poison. Return Zero either way.
+ // Checking this earlier saves us a lot of special cases later on.
+ Known.setAllZero();
+ return Known;
+ }
+
std::optional<APInt> Res;
if (LHS.isNegative() && RHS.isNegative()) {
// Result non-negative.
@@ -811,6 +818,13 @@
assert(!LHS.hasConflict() && !RHS.hasConflict());
KnownBits Known(BitWidth);
+ if (LHS.isZero() || RHS.isZero()) {
+ // Result is either known Zero or Poison. Return Zero either way.
+ // Checking this earlier saves us a lot of special cases later on.
+ Known.setAllZero();
+ return Known;
+ }
+
// We can figure out the minimum number of upper zero bits by doing
// MaxNumerator / MinDenominator. If the Numerator gets smaller or Denominator
// gets larger, the number of upper zero bits increases.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D150922.526345.patch
Type: text/x-patch
Size: 1723 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230528/f2fb50b1/attachment.bin>
More information about the llvm-commits
mailing list