Repository navigation
X86: Check if two addresses are equal in arraycmp - #6439
Conversation
If s1 and s2 points to the same address, jmp directly to equalLabel. Signed-off-by: Annabelle Huo <Annabelle.Huo@ibm.com>
|
@0xdaryl @vijaysun-omr May I ask you to review this change? Thank you! |
|
Is this short-circuit optimization applicable on the other platforms as well? |
The implementation of arraycmpEvaluator on other platforms look quite different to me.
|
@a7ehuo : Thanks for highlighting this. I suspect we simply never considered this case, but agree if the two source operands are identical, we can short circuit the logic. Did you happen to observe this pattern as common in some workload? |
|
Jenkins build xlinux,win,osx,x32linux |
|
@a7ehuo thanks for the reminder. i am also wondering how common this situation is in general workloads (e.g. dt7, acmeair, etc). |
|
I feel there is a bit of a tradeoff here, i.e. we will slightly increase the path length for arraycmps where the two addresses are not equal in order to significantly decrease the path length for arraycmps where the two addresses are equal. The latter case may not be common enough for this to be a net win (others seem to be expressing similar thoughts). |
|
In this particular case, just an extra branch is being added that piggybacks on an existing "test" (i.e, an explicit test for sameness is not being added to handle this case, just a branch). I believe that's an acceptable tradeoff. @vijaysun-omr : do you want more study done here? |
|
I would probably defer to your experience here @0xdaryl but I don't know if a study is warranted. It may well be something that is decided more on the basis of our judgement, e.g. what would the various instruction pipelines do. If the extra instruction is effectively expected to be "hidden" in most cases by the pipeline, then we could go ahead. If not, we may still go ahead but it is less clear-cut. |
|
I'm comfortable with the change on x64. A SUB and JE will macrofuse and dispatch in a single cycle. |
|
Okay, then we can go ahead on X86. Thanks. |
If s1 and s2 point to the same address, jmp directly to equalLabel.
Signed-off-by: Annabelle Huo Annabelle.Huo@ibm.com