This is an archive of the discontinued LLVM Phabricator instance.

Handle *_EXTEND_VECTOR_INREG during Integer Legalization
ClosedPublic

Authored by pirama on Oct 5 2016, 12:29 AM.

Details

Summary

These nodes need legalization for 3-element vectors. This commit
handles the legalization and adds tests for zext and sext.

This fixes PR30614.

Diff Detail

Repository
rL LLVM

Event Timeline

pirama updated this revision to Diff 73596.Oct 5 2016, 12:29 AM
pirama retitled this revision from to Handle *_EXTEND_VECTOR_INREG during Integer Legalization.
pirama updated this object.
pirama added reviewers: RKSimon, srhines.
pirama added a subscriber: llvm-commits.
RKSimon added inline comments.Oct 5 2016, 7:16 AM
lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp
3355 ↗(On Diff #73596)

Are you sure we're correctly handling the extension in this case? Promotion tends to leave the upper bits as garbage - won't we still need to perform a SIGN_EXTEND_INREG/ZERO_EXTEND_INREG.

test/CodeGen/X86/promote-vec3.ll
1 ↗(On Diff #73596)

Please use an -mattr=+ssse3 instead of a specific cpu target. Also test for SSE4.1 / AVX / AVX2 cases as well if you can, even though these probably don't use this new code path - just to check codegen.

Also please regenerate with utils\update_llc_test_checks.py

pirama added inline comments.Oct 5 2016, 10:46 AM
lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp
3355 ↗(On Diff #73596)

Aah, that's right. I couldn't craft a test IR where an EXTEND_VECTOR_INREG gets generated by DAGCombine that matches the actual TransformTo type. Maybe this is infeasible. I'll remove this separate handling.

test/CodeGen/X86/promote-vec3.ll
1 ↗(On Diff #73596)

'll add your suggested changes to this test.

I ran update_llc_test_checks and the checks seem to hard-code registers. Is this fine? (I've had issues in the past where hard-coded register values cause test failures on some bots where the RA picked a different set of registers).

pirama updated this revision to Diff 73672.Oct 5 2016, 10:58 AM

Removed direct reuse of promoted operand because it may not be extended properly.

Update test commands and generate checks using update_llc_test_checks.py.

RKSimon accepted this revision.Oct 6 2016, 11:51 AM
RKSimon edited edge metadata.

That's some pretty ugly codegen, but at least it doesn't crash any more!

One minor request but otherwise LGTM.

test/CodeGen/X86/promote-vec3.ll
5 ↗(On Diff #73672)

Please can you add at least one x86_64 test case?

1 ↗(On Diff #73596)

You've set the triple so this should be fine. Although its more likely that future changes may alter the (awful) codegen, the fact that its generated from the script makes it trivial to update.

This revision is now accepted and ready to land.Oct 6 2016, 11:51 AM
pirama updated this revision to Diff 73845.Oct 6 2016, 1:38 PM
pirama edited edge metadata.

Added x86_64 test for AVX2.

This revision was automatically updated to reflect the committed changes.
pirama added a comment.Oct 6 2016, 2:36 PM

Thanks for the review Simon. I've added the x86_64 test and committed this in r283496.