[PATCH] D53232: [LegalizeTypes] Prevent an assertion from PromoteIntRes_BSWAP and PromoteIntRes_BITREVERSE if the shift amount is too large for the VT returned by getShiftAmountTy

Craig Topper via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Oct 12 17:29:43 PDT 2018


craig.topper created this revision.
craig.topper added reviewers: eli.friedman, RKSimon, spatel.

getShiftAmountTy for X86 returns MVT::i8. If a BSWAP or BITREVERSE is created that requires promotion and the difference between the original VT and the promoted VT is more than 255 then we won't able to create the constant.

This patch adds a check to replace the result from getShiftAmountTy to MVT::i32 if the difference won't fit. This should get legalized later when the shift is ultimately expanded since its clearly an illegal type that we're only promoting to make it a power of 2 bit width. Alternatively we could base the decision completely on the largest shift amount the promoted VT could use.

Vectors should be immune here because getShiftAmountTy always returns the incoming VT for vectors. Only the scalar shift amount can be changed by the targets.


https://reviews.llvm.org/D53232

Files:
  lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp
  test/CodeGen/X86/bitreverse.ll
  test/CodeGen/X86/bswap.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D53232.169525.patch
Type: text/x-patch
Size: 36013 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20181013/14aa1ebc/attachment.bin>


More information about the llvm-commits mailing list