[PATCH] D93617: [DemandedBits] Add a whitelist when computing demanded bits of Trunc Instruction

guopeilin via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Dec 21 00:54:09 PST 2020


guopeilin added a comment.

So as the `avoid-truncate-shift-operands.ll`, before loop vectorize, we do a shift operation and then truncate its result into 8 bits. That is

  %0 = lshr i32 %f, 18
  %conv7 = trunc i32 %0 to i8

And the demanded bits says that we only need 8 bits of `%0`, so function `truncateToMinimalBitwidths()` firstly truncate `lshr`'s operands into 8 bits first, and then shift, which will cause a wrong result.

  %20 = trunc <2 x i32> %broadcast.splat7 to <2 x i8>
  %21 = lshr <2 x i8> %20, <i8 18, i8 18>
  %22 = zext <2 x i8> %21 to <2 x i32>
  %23 = trunc <2 x i32> %22 to <2 x i8>


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93617



More information about the llvm-commits mailing list