RFR: 8051725: Improve expansion of Conv2B nodes in the middle-end [v8]

Tobias Hartmann thartmann at openjdk.org
Wed May 24 06:23:57 UTC 2023


On Tue, 23 May 2023 07:09:37 GMT, Jasmine Karthikeyan <jkarthikeyan at openjdk.org> wrote:

>> Hi, I've created optimizations for the expansion of `Conv2B` nodes, especially when followed immediately by an xor of 1. This pattern is fairly common, and can arise from both [cmov idealization](https://github.com/openjdk/jdk/blob/master/src/hotspot/share/opto/movenode.cpp#L241) and [diamond-phi optimization](https://github.com/openjdk/jdk/blob/master/src/hotspot/share/opto/cfgnode.cpp#L1571). This change replaces `Conv2B` nodes in the middle-end during post loop opts IGVN with conditional moves on supported platforms (x86_64, aarch64, arm32), allowing the bit flip with `xor` to be subsumed with an inversion of the comparison instead. This change also reduces the overhead of the matcher in the backends, as fewer rules need to be traversed in order to match an ideal node. Performance results from my (Zen 2) machine:
>> 
>> 
>>                                     Baseline                           Patch              Improvement
>> Benchmark                      Mode  Cnt  Score    Error Units     Score    Error  Units
>> Conv2BRules.testEquals0        avgt   10  47.566 ± 0.346 ns/op  /  34.130 ± 0.177  ns/op  + 28.2%
>> Conv2BRules.testNotEquals0     avgt   10  37.167 ± 0.211 ns/op  /  34.185 ± 0.258  ns/op  + 8.0%
>> Conv2BRules.testEquals1        avgt   10  35.059 ± 0.280 ns/op  /  34.847 ± 0.160  ns/op  (unchanged)
>> Conv2BRules.testEqualsNull     avgt   10  56.768 ± 2.600 ns/op  /  34.330 ± 0.625  ns/op  + 39.5%
>> Conv2BRules.testNotEqualsNull  avgt   10  47.447 ± 1.193 ns/op  /  34.142 ± 0.303  ns/op  + 28.0%
>> 
>> Reviews would be greatly appreciated!
>> 
>> Testing: tier1-2 on linux x64, GHA
>
> Jasmine Karthikeyan has updated the pull request incrementally with one additional commit since the last revision:
> 
>   Cleanup from code review

I run this through some quick testing and I'm seeing the following crash with `compiler/vectorapi/TestMaskedMacroLogicVector.java` and `-XX:-TieredCompilation -XX:+AlwaysIncrementalInline`:


#  Internal Error (/workspace/open/src/hotspot/share/opto/type.hpp:1967), pid=3563106, tid=3563120
#  assert(_base == Int) failed: Not an Int
#
# JRE version: Java(TM) SE Runtime Environment (21.0) (fastdebug build 21-internal-LTS-2023-05-23-0846313.tobias.hartmann.jdk2)
# Java VM: Java HotSpot(TM) 64-Bit Server VM (fastdebug 21-internal-LTS-2023-05-23-0846313.tobias.hartmann.jdk2, mixed mode, sharing, compressed oops, compressed class ptrs, g1 gc, linux-amd64)
# Problematic frame:
# V  [libjvm.so+0x5cca5f]  Type::is_int() const [clone .part.0]+0x2f
#

Current CompileTask:
C2:   9002  777 %  b        compiler.vectorapi.TestMaskedMacroLogicVector::verifyInt2 @ 3 (136 bytes)

Stack: [0x00007f83d89e0000,0x00007f83d8ae1000],  sp=0x00007f83d8adb530,  free space=1005k
Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
V  [libjvm.so+0x5cca5f]  Type::is_int() const [clone .part.0]+0x2f  (type.hpp:1967)
V  [libjvm.so+0x5d2488]  XorINode::Ideal(PhaseGVN*, bool)+0x468  (node.hpp:394)
V  [libjvm.so+0x151c7fe]  PhaseIterGVN::transform_old(Node*)+0x22e  (phaseX.cpp:833)
V  [libjvm.so+0x1516141]  PhaseIterGVN::optimize()+0x81  (phaseX.cpp:1218)
V  [libjvm.so+0x9f3a12]  PhaseIdealLoop::optimize(PhaseIterGVN&, LoopOptsMode)+0x4d2  (loopnode.hpp:1203)
V  [libjvm.so+0x9efdae]  Compile::Optimize()+0x10fe  (compile.cpp:2350)
V  [libjvm.so+0x9f24c5]  Compile::Compile(ciEnv*, ciMethod*, int, Options, DirectiveSet*)+0x1ae5  (compile.cpp:839)
V  [libjvm.so+0x84c414]  C2Compiler::compile_method(ciEnv*, ciMethod*, int, bool, DirectiveSet*)+0x3c4  (c2compiler.cpp:118)
V  [libjvm.so+0x9fe2c0]  CompileBroker::invoke_compiler_on_method(CompileTask*)+0xa00  (compileBroker.cpp:2265)
V  [libjvm.so+0x9ff148]  CompileBroker::compiler_thread_loop()+0x618  (compileBroker.cpp:1944)
V  [libjvm.so+0xeb96fc]  JavaThread::thread_main_inner()+0xcc  (javaThread.cpp:719)
V  [libjvm.so+0x179b59a]  Thread::call_run()+0xba  (thread.cpp:217)
V  [libjvm.so+0x14980cc]  thread_native_entry(Thread*)+0x11c  (os_linux.cpp:775)

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

PR Comment: https://git.openjdk.org/jdk/pull/13345#issuecomment-1560518615


More information about the hotspot-compiler-dev mailing list