This is an archive of the discontinued LLVM Phabricator instance.

[ARM] Combine BFIs together
ClosedPublic

Authored by jmolloy on Nov 5 2015, 6:19 AM.

Details

Summary

If we have a chain of BFIs, we may be able to combine several together into one merged BFI.

We can do this if the "from" bits from one BFI OR'd with the "from" bits from the other BFI form a contiguous range, and the same with the "to" bits.

Hopefully the comments explain the concept better than I just did...

Diff Detail

Repository
rL LLVM

Event Timeline

jmolloy updated this revision to Diff 39360.Nov 5 2015, 6:19 AM
jmolloy retitled this revision from to [ARM] Combine BFIs together.
jmolloy updated this object.
jmolloy added reviewers: t.p.northover, mcrosier.
jmolloy set the repository for this revision to rL LLVM.
jmolloy added a subscriber: llvm-commits.
jmolloy updated this revision to Diff 39361.Nov 5 2015, 6:25 AM

Update diff - previous diff was accidentally a diff of a rebase.

jmolloy updated this revision to Diff 39362.Nov 5 2015, 6:28 AM

Hi Chad, Tim,

Do either of you have any comments on this?

Cheers,

James

Hi James,

I had a look at this patch (see comments inline).

Cheers,
Silviu

lib/Target/ARM/ARMISelLowering.cpp
9046

Is this correct? Maybe I'm not correctly understanding this.

For example A = 0b0011110000 (10 bits), LastActiveBitInA is 10 - 4 - 1 = 5, which doesn't look right.

Also, what happens when either A or B is 0?

9067

I think you need to expand this comment.

9138

Do you think it would be worth it to emit a SHR instead of bailing out here?

sbaranga added inline comments.Nov 11 2015, 4:35 AM
lib/Target/ARM/ARMISelLowering.cpp
9138

Ok, I didn't see the SHR here, ignore me.

jmolloy updated this revision to Diff 39904.Nov 11 2015, 5:10 AM
jmolloy marked an inline comment as done.

Hi Silviu,

New patch attached.

Cheers,

James

jmolloy marked 2 inline comments as done.Nov 11 2015, 5:11 AM
jmolloy added inline comments.
lib/Target/ARM/ARMISelLowering.cpp
9046

I was treating LastActiveBitInA and FirstActiveBitInB as numbering starting from the MSB. This was confusing, so I've swapped to LSB-based numbering.

9067

I thought about it again and there's nothing stopping us looking through a BFI with a different base.

sbaranga added inline comments.Nov 11 2015, 5:24 AM
lib/Target/ARM/ARMISelLowering.cpp
9067

Ok, but I think we still need to set the CombinedToMask in this case (otherwise we might not detect some conflicts).

jmolloy updated this revision to Diff 39905.Nov 11 2015, 5:35 AM

Thanks, LGTM!

-Silviu

mcrosier accepted this revision.Nov 11 2015, 9:04 AM
mcrosier edited edge metadata.
This revision is now accepted and ready to land.Nov 11 2015, 9:04 AM

James committed this in r252740.

James,
If this is something that would be worthwhile to implement in AArch64, please file a bug accordingly (assuming you're not planning on doing it yourself)? No sense in rediscovering the optimization in the future.

Chad

jmolloy closed this revision.Dec 12 2015, 5:36 AM

r253195.