[PATCH] Add Load Combine Pass

Michael Spencer bigcheesegs at gmail.com
Wed May 7 12:19:00 PDT 2014


atrick:
> It looks like you first sort the loads, then use load[0] as the insertion point. How does this work if the loads are striding backward through memory with uses in between?

Oops. That is a problem. I did a backward test, but it didn't have a use of the value in-between the loads. I suppose I could also store the original insertion order...

> Since you are effectively hoisting loads, I think you should check mayThrow(), not just mayWriteMemory(). In the future, we will want to support read-only calls that mayThrow. (This would allow redundant load elimination across the calls--important for runtime safety checks.)

I thought only terminating instructions can throw?

As for targets that have to split unaligned loads. I tested the original case on ARM and llvm actually generates slightly better code when SDAG splits the combined load than if we just leave it alone. I'll check other targets, but I believe that we do a pretty good job splicing. The only bad cases I ran into were where the combined load isn't actually used combined, it's just directly resplit via shr/trunc. Here I believe we will need to teach SDAG to split these loads back up, but that should be easy (but should be done before this lands).

http://reviews.llvm.org/D3580






More information about the llvm-commits mailing list