[PATCH] D154717: [LV] Check if ops can safely be truncated in computeMinimumValueSizes.

Florian Hahn via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Jul 7 14:03:15 PDT 2023


fhahn marked 3 inline comments as done.
fhahn added inline comments.


================
Comment at: llvm/lib/Analysis/VectorUtils.cpp:678
+              if (I.trunc(MinBW).zext(I.getBitWidth()) == I)
+                return false;
+            }
----------------
nikic wrote:
> Hm, is this special case for constants correct? Consider a variant on the test case that does something like `%l = shl i32 %f, 24`. Then only the low 8 bits of `%f` would be demanded, and `24` can be truncated to 8 bits, but it still changes the result: Now the shift would return poison (while previously the shl + trunc would produce zero).
Yep, it seems like there are multiple issues with this code. For the `lshr` case, DemandedBits seems sufficient to rule out narrowing (by making sure we don't drop bits contributing to the result).

In addition to that for the `shl` case (and others where smaller widths may cause new poison), we would also need to take into account the semantics of the specific instructions. Do we have any existing APIs that would be suitable to check?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154717



More information about the llvm-commits mailing list