This is an archive of the discontinued LLVM Phabricator instance.

[SelectionDAG] Fix incorrect condition for shift amount truncation
ClosedPublic

Authored by nextsilicon-itay-bookstein on Sep 26 2021, 1:07 PM.

Details

Summary

Comment says:

// If the operand is larger than the shift count type but the shift
// count type has enough bits to represent any shift value ...

It clearly talks about the shifted operand, not the shift-amount operand,
but the comparison is performed against Log2_32_Ceil(Op2.getValueSizeInBits())
where Op2 is the shift amount operand. This comparison also doesn't make
sense in the context of the previous one (ShiftsSize > Op2Size) because
Op2Size == Op2.getValueSizeInBits(). Fix to use Op1.

Diff Detail

Event Timeline

nextsilicon-itay-bookstein requested review of this revision.Sep 26 2021, 1:07 PM
Herald added a project: Restricted Project. · View Herald TranscriptSep 26 2021, 1:07 PM
craig.topper accepted this revision.Sep 26 2021, 2:37 PM

I think Op1 and Op2 are the same size at this point in the code due to the requirements of the IR operation. But this is more readable.

LGTM

This revision is now accepted and ready to land.Sep 26 2021, 2:37 PM

True, at SelectionDAGBuilder time that invariant holds. So just speedbump removal / potential copypasta bug prevention? 😛

I have no commit access, might I ask that you commit this on my behalf?

Author: Itay Bookstein <itay.bookstein@nextsilicon.com>

This revision was landed with ongoing or failed builds.Sep 28 2021, 5:52 PM
This revision was automatically updated to reflect the committed changes.