This is an archive of the discontinued LLVM Phabricator instance.

[NFC] CodeGen: Handle shift amount type in DAGTypeLegalizer::SplitInteger
ClosedPublic

Authored by yaxunl on Nov 21 2017, 1:34 PM.

Details

Summary

This patch reverts change to X86TargetLowering::getScalarShiftAmountTy in
rL318727 and move the logic to DAGTypeLegalizer::SplitInteger.

The reason is that getScalarShiftAmountTy returns a shift amount type that
is suitable for common use cases in CodeGen. DAGTypeLegalizer::SplitInteger
is a rare situation which requires a shift amount type larger than what
getScalarShiftAmountTy. In this case, it is more reasonable to do special
handling of shift amount type in DAGTypeLegalizer::SplitInteger only. If
similar situations arises the logic may be moved to a separate function.

Since this is NFC, existing lit tests are sufficient.

Diff Detail

Repository
rL LLVM

Event Timeline

yaxunl created this revision.Nov 21 2017, 1:34 PM
efriedma added inline comments.Nov 21 2017, 2:25 PM
lib/CodeGen/SelectionDAG/LegalizeTypes.cpp
1175 ↗(On Diff #123839)

Log2_32_Ceil?

yaxunl added inline comments.Nov 21 2017, 2:42 PM
lib/CodeGen/SelectionDAG/LegalizeTypes.cpp
1175 ↗(On Diff #123839)

It is different. E.g, the number 32 requires 6 bits to hold, but Log2_32_Ceil(32) == 5.

efriedma added inline comments.Nov 21 2017, 3:02 PM
lib/CodeGen/SelectionDAG/LegalizeTypes.cpp
1175 ↗(On Diff #123839)

Sure, but "32" isn't a legal shift amount for an i32.

Oh, wait, I see, you're not using the type I expected. I was expecting something like Log2_32_Ceil(Op.getValueType().getSizeInBits()). (I guess that's equivalent to what you wrote, but it's a bit more intuitive since Op.getValueType() is the type of the shift.)

yaxunl updated this revision to Diff 123876.Nov 21 2017, 7:30 PM

Revised by Eli's comments.

lib/CodeGen/SelectionDAG/LegalizeTypes.cpp
1175 ↗(On Diff #123839)

Revised. Thanks.

This revision is now accepted and ready to land.Nov 22 2017, 12:26 PM
This revision was automatically updated to reflect the committed changes.