This is an archive of the discontinued LLVM Phabricator instance.

[DAGCombiner] Support non-zero offset in load combine
ClosedPublic

Authored by apilipenko on Feb 1 2017, 6:36 AM.

Details

Summary

Enable folding patterns which load the value from non-zero offset:

i8 *a = ...
i32 val = a[4] | (a[5] << 8) | (a[6] << 16) | (a[7] << 24)

>

i32 val = *((i32*)(a+4))

Diff Detail

Event Timeline

apilipenko created this revision.Feb 1 2017, 6:36 AM
apilipenko edited the summary of this revision. (Show Details)Feb 1 2017, 6:36 AM
boris.ulasevich added inline comments.
test/CodeGen/AArch64/load-combine-big-endian.ll
203

Just a question.. This inefficient implementation should be optimised in spite of non-zero offset. How do we check the optimisation works Ok?

RKSimon edited edge metadata.Feb 3 2017, 8:54 AM

Please can you commit the new tests to trunk now with their current codegen and then update this patch to show the delta in codegen - I think this will answer @boris.ulasevich 's concerns.

apilipenko updated this revision to Diff 87222.Feb 6 2017, 7:02 AM

The test cases have been landed separately (rL294185), rebase the patch.

One minor

lib/CodeGen/SelectionDAG/DAGCombiner.cpp
4588

Add an assert that ensures FirstOffset has a sane value.

apilipenko updated this revision to Diff 87659.Feb 8 2017, 7:48 AM

Add an assert as suggested.

RKSimon accepted this revision.Feb 8 2017, 8:44 AM

LGTM

This revision is now accepted and ready to land.Feb 8 2017, 8:44 AM
This revision was automatically updated to reflect the committed changes.