This is an archive of the discontinued LLVM Phabricator instance.

[DAG] Fix incorrect alignment of ext load.
ClosedPublic

Authored by niravd on Aug 10 2016, 9:28 AM.

Details

Summary

Correctly use alignment size from loaded size not output value size.

Diff Detail

Repository
rL LLVM

Event Timeline

niravd updated this revision to Diff 67536.Aug 10 2016, 9:28 AM
niravd retitled this revision from to [DAG] Fix incorrect alignment of ext load..
niravd added a reviewer: jyknight.
niravd updated this object.
niravd added a subscriber: llvm-commits.
arsenm added a subscriber: arsenm.Aug 10 2016, 9:40 AM
arsenm added inline comments.
test/CodeGen/AMDGPU/extload.ll
1 ↗(On Diff #67536)

Can you do something else that doesn't use -debug? This will break in release build

69 ↗(On Diff #67536)

this should use a positive check

Where is the call site passing 0 alignment?

niravd updated this revision to Diff 67564.Aug 10 2016, 11:25 AM
niravd marked 2 inline comments as done.
niravd edited edge metadata.

Use different debug flag for tests

The 0 alignment load is coming from the splitting of the extract_vector_elt.

Where is the call site passing 0 alignment?

The 0 alignment load is coming from the splitting of the extract_vector_elt.

Where is the call site passing 0 alignment?

Could you be more specific?

test/CodeGen/AMDGPU/extload.ll
1 ↗(On Diff #67564)

-debug-only will have the same problem that this will only work in asserts build

niravd added a comment.Sep 1 2016, 6:53 AM

In the SplitVecOp_EXTRACT_VECTOR_ELT(N) in LegalizeVectorTypes, there is a call to DAG.getExtLoad where the optional Alignment argument is omitted and defaulted to 0.
This appears to be the only call in llvm of such that triggers that code path and all other similar alignment checks appear correct.

In terms of a test, it's not clear to me how to expose the issue with alignment from an element of a decomposed vector in the current upstream without inspecting intermediate state via debug. The easiest way would be to fold this into D14834. I'd prefer to make this a separate commit as it is an obvious and separable mistake. Perhaps we could add this test for now, and then delete it as redundant with D14834.

The 0 alignment load is coming from the splitting of the extract_vector_elt.

Where is the call site passing 0 alignment?

Could you be more specific?

niravd updated this revision to Diff 70408.Sep 6 2016, 9:02 AM

Fix test so that it only runs for assert builds.

hfinkel added inline comments.
test/CodeGen/AMDGPU/extload-align.ll
5 ↗(On Diff #70408)

It is not obvious what you're checking here. Do you want to match the alignment? (or are you matching the lack of a non-default alignment)?

niravd updated this revision to Diff 70438.Sep 6 2016, 11:31 AM

Add comment explaining test

test/CodeGen/AMDGPU/extload-align.ll
5 ↗(On Diff #70408)

That's correct. I'm checking that the alignment is 2 and matching the underlying i16 load, not 4 matching the size of the extend value. I've added a comment to the test making this clearer.

hfinkel accepted this revision.Sep 21 2016, 9:17 PM
hfinkel added a reviewer: hfinkel.

LGTM.

This revision is now accepted and ready to land.Sep 21 2016, 9:17 PM
This revision was automatically updated to reflect the committed changes.