Intrinsics for Math.min and max

Andrew Haley aph at redhat.com
Wed Apr 2 14:22:17 UTC 2014


On 04/02/2014 02:03 PM, Vitaly Davidovich wrote:
> You mean substantial unrolling occurs with certain probabilities?

It seems to.  My experiment was to make the branch totally unpredictable,
in which case the intrinsic is no better than the user-defined
Math.max.

> I think that's where the cmov really hurts (for predictable
> branches) as the cpu will be slowed down by dependency chains.
> 
> As I mentioned in my other reply, it's hard to build a software
> model of a branch prediction unit as they're not simple probability
> counters but look at branch patterns.  I think best hotspot can do
> here is just record highly likely/unlikely code paths, but leave the
> gray area alone (i.e. prefer jumps).

As far as I can see from x86, there aren't really any cases where the
intrinsic is useful.  In some cases HotSpot generates cmov with user-
defined Math.max, depending on probability.  Simply deleting the
intrinsic would be no bad thing, judging from these results.

Andrew.


More information about the hotspot-compiler-dev mailing list