An address only use of an extract element of a load can be simplified to a
load. Without this the result of the extract element is spilled to the
stack so that an address is available.
Details
Diff Detail
Event Timeline
This looks like a really nice improvement, and you're right, probably not just for x86.
I suggest looking into making this a target-independent DAG combine that can be predicated on queries to TargetLowering about what types and operations are legal to see when it's profitable. I suspect this is going to be the right thing to do for pretty much all CPU targets.
Hi Michael,
DAGCombiner has a load slicing mechanism what tries to produce target friendly loads. Maybe we could extend this mechanism to handle this kind of cases.
Do not know how easy that would be, but that seems to me like the natural place to start :).
You can take a look at DAGCombiner::SliceUpLoad.
Thanks,
-Quentin
Hi Michael,
This LGTM with one remark, I leave it to you whether or not you want to address it since Nadav already gave his LGTM.
I do not particularly like the use of the lambda here. I think it would have been clearer to explicitly add the few more variables that we use (ConstEltNode, NewLowd, EltNo) and have a new (documented) private member function.
I see two advantages of using a member function instead of the lambda:
- DAGCombiner::visitEXTRACT_VECTOR_ELT would be easier to read and understand.
- The member function can be properly documented.
What do you think?
Thanks,
-Quentin