[PATCH] D108091: [AggressiveInstCombine] Add shift left instruction to `TruncInstCombine` DAG

Sanjay Patel via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun Aug 15 14:09:10 PDT 2021


spatel added a comment.

In D108091#2945739 <https://reviews.llvm.org/D108091#2945739>, @lebedev.ri wrote:

> @spatel this appears correct, but is this the right place for this logic, or should it be in `getMinBitWidth()`?

Hmm...I haven't looked at this code much before, so I'm not sure yet.



================
Comment at: llvm/test/Transforms/AggressiveInstCombine/trunc_shifts.ll:36-37
   %zext = zext i8 %x to i32
   %shl = shl i32 %zext, 16
   %trunc = trunc i32 %shl to i16
   ret i16 %trunc
----------------
If the left shift amount >= the truncated bit-width, the result must be 0.
Looks like -instcombine gets this, but not -instsimplify. 
Can we adjust this test to something that does not completely fold away?


================
Comment at: llvm/test/Transforms/AggressiveInstCombine/trunc_shifts.ll:49
   %zext = zext i8 %x to i32
   %shl = shl i32 %zext, %zext
   %trunc = trunc i32 %shl to i16
----------------
If the intent is to check for a shift amount with no known bits, it would be better to just add a function argument `%y`, so we're not mixing up that constraint with number of uses or some other factor.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108091



More information about the llvm-commits mailing list