[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:31:13 PST 2020


guopeilin added a comment.

Firstly, let's take `avoid-truncate-icmp-operands.ll` as an example to explain this patch.<br>
Before running loop vectorize pass, we can see that in the basic block `if.then`, we compare value `d` and value `e`, and select one of them based on the comparison.<br>
However after loop vectorize pass, we wrongly truncate instruction `icmp`'s operands firstly,

  %3 = trunc <2 x i64> %broadcast.splat to <2 x i16>
   %4 = trunc <2 x i64> %broadcast.splat4 to <2 x i16>
   %5 = icmp ult <2 x i16> %3, %4
   %6 = trunc <2 x i64> %broadcast.splat4 to <2 x i16>
   %7 = trunc <2 x i64> %broadcast.splat to <2 x i16>
   %8 = select <2 x i1> %5, <2 x i16> %6, <2 x i16> %7
   %9 = zext <2 x i16> %8 to <2 x i64>
   %10 = trunc <2 x i64> %9 to <2 x i16>

That is we only compare the lower 16 bits of value `d` and value `e`, which will cause the wrong answer because lower bits cannot represent comparison of the whole bits.


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