[DAGCombiner] Replace a hardcoded constant in visitZERO_EXTEND with a proper check...
authorCraig Topper <craig.topper@gmail.com>
Mon, 6 Apr 2020 02:26:15 +0000 (19:26 -0700)
committerCraig Topper <craig.topper@gmail.com>
Mon, 6 Apr 2020 03:35:57 +0000 (20:35 -0700)
commit586c051a27070fc7fa3b04f220ed2b3e73c685b7
tree8fa0836563213d1d789dc60eb2d8ae60399bfc2f
parent8b3b7556e9ab6084e9fd337d64dac1c165867d32
[DAGCombiner] Replace a hardcoded constant in visitZERO_EXTEND with a proper check for the condition its trying to protect.

This code is replacing a shift with a new shift on an extended type.
If the shift amount type can't represent the maximum shift amount
for the new type, the amount needs to be extended to a type that
can.

Previously, the code just hardcoded a check for 256 bits which
seems to have been an assumption that the original shift amount
was MVT::i8. But that seems more catered to a specific target
like X86 that uses i8 as its legal shift amount type. Other
targets may use different types.

This commit changes the code to look at the real type of the shift
amount and makes sure it has enough bits for the Log2 of the
new type. There are similar checks to this in SelectionDAGBuilder
and LegalizeIntegerTypes.
llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp