This is an archive of the discontinued LLVM Phabricator instance.

[AArch64]Extend merging narrow loads into a wider load
ClosedPublic

Authored by junbuml on Oct 29 2015, 12:21 PM.

Details

Summary

This change extends r251438 to handle more narrow load promotions
including byte type, unscaled, and signed. For example, this change will
convert :

ldursh w1, [x0, #-2]
ldurh  w2, [x0, #-4]

into

ldur  w2, [x0, #-4]
asr   w1, w2, #16
and   w2, w2, #0xffff

Diff Detail

Event Timeline

junbuml updated this revision to Diff 38753.Oct 29 2015, 12:21 PM
junbuml retitled this revision from to [AArch64]Extend merging narrow loads into a wider load.
junbuml updated this object.
junbuml added reviewers: jmolloy, ab, mzolotukhin, mcrosier.
mcrosier edited edge metadata.Nov 2 2015, 6:18 AM

Jun,
You might consider breaking this up into two separate patches:

  1. Add the enableNarrowLdPromotion() functionality to address James' concern about this change not necessarily being profitable on all targets.
  2. Add the functional change for merging additional narrow loads into wider loads.

    Chad
lib/Target/AArch64/AArch64LoadStoreOptimizer.cpp
87

I don't think you need a member variable. See my comment below.

1251

Please add a period.

1276

Why not have enableNarrowLdPromotion(MBB->getParent()) return a bool and call it here directly, rather than store in a member variable? AFAICT, this is the only use.

junbuml updated this revision to Diff 39106.Nov 3 2015, 1:20 PM
junbuml edited edge metadata.

As Chad suggested, I posted a separate patch (D14244) which address James' concern about enabling this conversion only in profitable targets.

junbuml updated this revision to Diff 39688.Nov 9 2015, 6:53 AM

Minor update in comments.

Jun,
Does this hit any cases in Spec2000, Spec2006 or the test-suite? If so, do you have any performance numbers?

Chad

This change is applied in many spec2000/2006 benchmarks, but I wasn't able to see clear performance differences from this patch.

junbuml updated this revision to Diff 39934.Nov 11 2015, 9:08 AM
junbuml added a reviewer: t.p.northover.
junbuml added a subscriber: flyingforyou.

Rebased this change and updated unit-tests.

junbuml updated this revision to Diff 40054.Nov 12 2015, 8:00 AM

Just removed whitespace

jmolloy requested changes to this revision.Nov 12 2015, 9:11 AM
jmolloy edited edge metadata.
jmolloy added inline comments.
lib/Target/AArch64/AArch64LoadStoreOptimizer.cpp
209

Let's use "isNarrowLoad" here. No need for truncations when it adds nothing.

588

Wouldn't it be more obvious to just use:

assert(OffsetImm & 1 == 0)?
616

These magic numbers look very easy to get wrong. Is there no obvious programmatic way of deriving them?

1231

Why have you done this rename in the same patch? This clutters the patch.

1473

This stuff should not be in the same patch as a functional change. Please separate out the patches.

This revision now requires changes to proceed.Nov 12 2015, 9:11 AM

Thanks James for your review. I will address your comments and update it soon.

lib/Target/AArch64/AArch64LoadStoreOptimizer.cpp
209

As you point out below, I will keep the same function name in this patch and will post a separate patch only for renaming.

588

I will update this. Thanks!

616

I agree with your comment. Let me update this in more programmatic way!

1231

Let me keep the same function name in this patch. I will add a separate patch only for renaming.

1473

This was a minor refactoring as D14534 introduced Subtarget as a member variable. I understand this is not perfectly related with this change. I will do this in a separate refactoring patch.

junbuml updated this revision to Diff 40067.Nov 12 2015, 10:42 AM
junbuml edited edge metadata.

Addressed James' comments.

Ping? Please let me know any comment !

mcrosier accepted this revision.Nov 19 2015, 7:48 AM
mcrosier edited edge metadata.

LGTM with a minor nit. Please make sure the refactoring of isSmallTypeLdMerge->isNarrowLoad, etc lands after this..

lib/Target/AArch64/AArch64LoadStoreOptimizer.cpp
616

In general, variable names should begin with a capital letter and are written in camel case.

width -> Width
lsbLow -> LSBLow or LsbLow
lsbHigh -> LSBHigh or LsbHigh
immsLow -> ImmsLow
immsHigh -> ImmsHigh

jmolloy accepted this revision.Nov 19 2015, 7:53 AM
jmolloy edited edge metadata.
This revision is now accepted and ready to land.Nov 19 2015, 7:53 AM

Thanks James and Chad for the review!

lib/Target/AArch64/AArch64LoadStoreOptimizer.cpp
616

Oh. Yes. I will fix it !

junbuml closed this revision.Nov 19 2015, 9:31 AM

Landed in r253577.