This is an archive of the discontinued LLVM Phabricator instance.

[X86][MMX] Fix folding of shift value loads to cover whole 64-bits
ClosedPublic

Authored by RKSimon on Mar 10 2017, 8:48 AM.

Details

Summary

rL230225 made the assumption that only the lower 32-bits of an MMX register load is used as a shift value, when in fact the whole 64-bits are reloaded and treated as a i64 to determine the shift value.

This patch reverts rL230225 to ensure that the whole 64-bits of memory are folded and ensures that the upper 32-bit are zero'd for cases where the shift value has come from a scalar source.

Found during fuzz testing.

Diff Detail

Repository
rL LLVM

Event Timeline

RKSimon created this revision.Mar 10 2017, 8:48 AM
andreadb accepted this revision.Mar 13 2017, 11:33 AM

Looks good to me.

I agree that reverting the original commit is the right thing to do. All those mmx patterns were incorrectly bypassing the zeroing of the upper half of the shift count.
The original shift count came from a MMX_MOVW2D node (which is equivalent to a cast from v2i32 to x86mmx of a BUILD_VECTOR that explicitly zeroes the second element).

This revision is now accepted and ready to land.Mar 13 2017, 11:33 AM
This revision was automatically updated to reflect the committed changes.