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

Anton Afanasyev via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun Aug 15 22:51:59 PDT 2021


anton-afanasyev added inline comments.


================
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
----------------
spatel wrote:
> 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?
Hmm, yes, you're right. But this could be adjusted only if shift amount is variable, this case is covered by `@shl_var_not_commute()` function below. I can only remove this test at all.


================
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
----------------
spatel wrote:
> 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.
Ok, done


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