[PATCH] D83127: [InstCombine] canEvaluateTruncated - use KnownBits to check for inrange shift amounts

Simon Pilgrim via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Jul 3 05:54:00 PDT 2020


RKSimon created this revision.
RKSimon added reviewers: spatel, lebedev.ri, fhahn.
Herald added a subscriber: hiraditya.
Herald added a project: LLVM.

Currently canEvaluateTruncated can only attempt to truncate shifts if they are scalar/uniform constant amounts that are in range.

This patch replaces the constant extraction code with KnownBits handling, using the KnownBits::getMaxValue to check that the amounts are inrange.

This enables support for nonuniform constant cases, and also variable shift amounts that have been masked somehow. Annoyingly, this still won't work for vectors with (demanded) undefs as KnownBits returns nothing in those cases, but its a definite improvement on what we currently have.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D83127

Files:
  llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp
  llvm/test/Transforms/InstCombine/2008-01-21-MulTrunc.ll
  llvm/test/Transforms/InstCombine/cast.ll
  llvm/test/Transforms/InstCombine/trunc.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D83127.275377.patch
Type: text/x-patch
Size: 13645 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200703/c4ac1c00/attachment.bin>


More information about the llvm-commits mailing list