RFR: 8335444: Generalize implementation of AndNode mul_ring

Christian Hagedorn chagedorn at openjdk.org
Wed Jul 31 18:41:34 UTC 2024


On Wed, 31 Jul 2024 08:47:22 GMT, Christian Hagedorn <chagedorn at openjdk.org> wrote:

>> Hi all,
>> I've written this patch which improves type calculation for bitwise-and functions. Previously, the only cases that were considered were if one of the inputs to the node were a positive constant. I've generalized this behavior, as well as added a case to better estimate the result for arbitrary ranges. Since these are very common patterns to see, this can help propagate more precise types throughout the ideal graph for a large number of methods, making other optimizations and analyses stronger. I was interested in where this patch improves types, so I ran CTW for `java_base` and `java_base_2` and printed out the differences in this gist [here](https://gist.github.com/jaskarth/b45260d81ab621656f4a55cc51cf5292). While I don't think it's particularly complicated I've also added some discussion of the mathematics below, mostly because I thought it was interesting to work through :)
>> 
>> This patch passes tier1-3 testing on my linux x64 machine. Thoughts and reviews would be very appreciated!
>
> Not a review but I quickly ran it through our testing and the following test fails with `-XX:UseAVX=3` on linux-x64-debug and windows-x64-debug and without any flags on windows-x64-debug which seems to be related to your patch:
> 
> Test: compiler/vectorization/runner/BasicBooleanOpTest.java
> 
> Output:
> 
> Failed IR Rules (1) of Methods (1)
> ----------------------------------
> 1) Method "public boolean[] compiler.vectorization.runner.BasicBooleanOpTest.vectorAnd()" - [Failed IR rules: 1]:
>    * @IR rule 3: "@compiler.lib.ir_framework.IR(phase={DEFAULT}, applyIfPlatformAnd={}, applyIfCPUFeatureOr={}, counts={"_#MACRO_LOGIC_V#_", ">0"}, failOn={}, applyIfPlatform={}, applyIfPlatformOr={}, applyIfOr={}, applyIfCPUFeatureAnd={}, applyIf={}, applyIfCPUFeature={"avx512f", "true"}, applyIfAnd={}, applyIfNot={})"
>      > Phase "PrintIdeal":
>        - counts: Graph contains wrong number of nodes:
>          * Constraint 1: "MacroLogicV"
>            - Failed comparison: [found] 0 > 0 [given]
>            - No nodes matched!

> Thank you for running testing @chhagedorn! I think I didn't run into this because my device doesn't support AVX-512. Does the failure have an ideal node printout as well? I think that could help in diagnosing the issue. Thanks!

Sure, here is the log file for linux-x64-debug: [test_failure.log](https://github.com/user-attachments/files/16445886/test_failure.log)

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

PR Comment: https://git.openjdk.org/jdk/pull/20066#issuecomment-2261171583


More information about the hotspot-compiler-dev mailing list