This is an archive of the discontinued LLVM Phabricator instance.

[GlobalISel][Legalizer] Widening the second src op of shifts bug fix
ClosedPublic

Authored by rtereshin on May 3 2018, 4:59 PM.

Details

Summary

The second source operand of G_SHL, G_ASHR, and G_LSHR must preserve its
value as a (small) unsigned integer, therefore its incorrect to widen it
in any way but by zero extending it.

G_SHL was using G_ANYEXT and G_ASHR - G_SEXT (which is correct for their
destination and first source operands, but not the "number of bits to
shift" operand).

Generally, shifts aren't as similar to regular binary operations as it
might seem, for instance, they aren't commutative nor associative and
the second source operand usually requires a special treatment.

Diff Detail

Repository
rL LLVM

Event Timeline

rtereshin created this revision.May 3 2018, 4:59 PM
bogner added a comment.May 3 2018, 5:26 PM

Looks good, but please use update_llc_test_checks for the existing tests and move the test with the explanation to its own file

rtereshin updated this revision to Diff 145123.May 3 2018, 5:59 PM

Updated x86 tests with the script and moved my own into a separate file.

rtereshin updated this revision to Diff 145127.May 3 2018, 6:09 PM

Oops, squashed this with https://reviews.llvm.org/D46414 accidentally, changing it back.

bogner accepted this revision.May 4 2018, 11:01 AM

lgtm, thanks!

This revision is now accepted and ready to land.May 4 2018, 11:01 AM
rtereshin added a subscriber: igorb.May 8 2018, 2:09 PM
This revision was automatically updated to reflect the committed changes.