On Fri, 24 Apr 2026 08:23:15 GMT, Galder Zamarreño <[email protected]> wrote:

> Applied the fixes as suggested in the issue. I applied the fix in #30900 on 
> top of the fix in this PR to observe the differences.
> 
> Before the fix, one would see:
> 
> 
> $ 
> TEST="micro:org.openjdk.bench.java.lang.MinMaxVector.longReductionSimpleMax" 
> MICRO="FORK=1;OPTIONS=-p probability=100 -jvmArgsAppend -XX:-UseSuperWord 
> -jvmArgsAppend -XX:+PrintMethodData" make test
> ...
> ------------------------------------------------------------------------
> static java.lang.Math::max(JJ)J
>   interpreter_invocation_count:      488657
>   invocation_counter:                488657
>   backedge_counter:                       0
>   decompile_count:                        0
>   mdo size: 328 bytes
> 
>    0 lload_0
>    1 lload_2
>    2 lcmp
>    3 iflt 10
>   0    bci: 3    BranchData         taken(447750) displacement(56)
>                                     not taken(40372)
>    6 lload_0
>    7 goto 11
>   32   bci: 7    JumpData           taken(40372) displacement(24)
>   10 lload_2
>   11 lreturn
> 
> 
> We see that branch taken is ~90% instead of the desired 100%. Also, the high 
> branch taken is the opposite of what the `probability` java doc states.
> 
> After the fix we see:
> 
> 
> $ 
> TEST="micro:org.openjdk.bench.java.lang.MinMaxVector.longReductionSimpleMax" 
> MICRO="FORK=1;OPTIONS=-p probability=100 -jvmArgsAppend -XX:-UseSuperWord 
> -jvmArgsAppend -XX:+PrintMethodData" make test
> ...
> static java.lang.Math::max(JJ)J
>   interpreter_invocation_count:      551119
>   invocation_counter:                551119
>   backedge_counter:                       0
>   decompile_count:                        0
>   mdo size: 328 bytes
> 
>    0 lload_0
>    1 lload_2
>    2 lcmp
>    3 iflt 10
>   0    bci: 3    BranchData         taken(1721) displacement(56)
>                                     not taken(548864)
>    6 lload_0
>    7 goto 11
>   32   bci: 7    JumpData           taken(548865) displacement(24)
>   10 lload_2
>   11 lreturn
> 
> 
> With the fix the branch not taken is ~99%, which is almost the 100% we 
> defined in the probability. Also, the branch not taken aligns with the 
> behavior specified in the java doc of `probability`.
> 
> ---------
> - [X] I confirm that I make this contribution in accordance with the [OpenJDK 
> Interim AI Policy](https://openjdk.org/legal/ai).

This pull request has now been integrated.

Changeset: af9ed6c0
Author:    Galder Zamarreño <[email protected]>
URL:       
https://git.openjdk.org/jdk/commit/af9ed6c02262545121843950e71eb78aeea73f30
Stats:     17 lines in 1 file changed: 1 ins; 0 del; 16 mod

8382881: Swap min/max values and avoid equals min/max values in MinMaxVector

Reviewed-by: roland

-------------

PR: https://git.openjdk.org/jdk/pull/30912

Reply via email to