On Thu, 2012-05-03 at 09:40 -0600, Jeff Law wrote:
> On 05/03/2012 08:33 AM, William J. Schmidt wrote:
> > This patch was posted for comment back in February during stage 4. It
> > addresses a performance issue noted in the EEMBC routelookup benchmark
> > on a common idiom:
> > if (...)
> > x = y->left;
> > else
> > x = y->right;
> > If the two loads can be hoisted out of the if/else, the if/else can be
> > replaced by a conditional move instruction on architectures that support
> > one. Because this speculates one of the loads, the patch constrains the
> > optimization to avoid introducing page faults.
> > Bootstrapped and regression tested on powerpc-unknown-linux-gnu with no
> > new failures. The patch provides significant improvement to the
> > routelookup benchmark, and is neutral on SPEC cpu2000/cpu2006.
> > One question is what optimization level should be required for this.
> > Because of the speculation, -O3 might be in order. I don't believe
> > -Ofast is required as there is no potential correctness issue involved.
> > Right now the patch doesn't check the optimization level (like the rest
> > of the phi-opt transforms), which is likely a poor choice.
> Doesn't this need to be conditionalized on the memory model that's
> currently active?
Yes and no. What's important is that you don't want to introduce page
faults (or less urgently, cache misses) by speculating the load. So the
patch is currently extremely constrained, and likely will always stay
that way. Only fields that are pointers and that are strictly adjacent
are hoisted, and only if they're in the same 16-byte block. (The number
16 is a parameter that can be adjusted.)
Hopefully I didn't miss your point -- let me know if I did and I'll try