[12] RFR(M): 8210215: C2 should optimize trichotomy calculations
Tobias Hartmann
tobias.hartmann at oracle.com
Tue Oct 2 07:20:05 UTC 2018
Hi Vladimir,
On 01.10.2018 20:00, Vladimir Kozlov wrote:
> We already have this optimization (for no Phi nodes) in RegionNode::Ideal() [1]:
>
> http://hg.openjdk.java.net/jdk/jdk/file/2f1698b6db15/src/hotspot/share/opto/cfgnode.cpp#l432
>
> I don't think we need to duplicate it here - just return false. Did you found that it does not work
> in your case?
That optimization only works if the region has no phi users but for shape 2, the region *has* a phi
user. We can only remove the if because we know that the phi is merging the same value 'x':
If
/ \
Proj Proj
\ / [...]
\ / /
Region1
|
| x x y
\ | | /
Phi
For example, without this, TestTrichotomyExpressions::testEqual7 is not optimized. Below is the
ideal graph for this test, node 41 is the corresponding region and 44 is the useless if because the
only phi user 71 returns the same value for inputs 1 and 2.
Thanks,
Tobias
Ideal graph for TestTrichotomyExpressions::testEqual7:
0 Root === 0 65 [[ 0 1 3 40 49 51 ]] inner
11 Parm === 3 [[ 33 ]] Parm1: int !jvms: TestTrichotomyExpressions::testEqual7 @ bci:-1
10 Parm === 3 [[ 33 ]] Parm0: int !jvms: TestTrichotomyExpressions::testEqual7 @ bci:-1
33 CmpI === _ 10 11 [[ 34 43 ]] !jvms: TestTrichotomyExpressions::compare7 @ bci:2
TestTrichotomyExpressions::testEqual7 @ bci:2
34 Bool === _ 33 [[ 35 ]] [ne] !jvms: TestTrichotomyExpressions::compare7 @ bci:2
TestTrichotomyExpressions::testEqual7 @ bci:2
5 Parm === 3 [[ 35 ]] Control !jvms: TestTrichotomyExpressions::testEqual7 @ bci:-1
43 Bool === _ 33 [[ 44 ]] [lt] !jvms: TestTrichotomyExpressions::compare7 @ bci:11
TestTrichotomyExpressions::testEqual7 @ bci:2
36 IfTrue === 35 [[ 44 ]] #1 !jvms: TestTrichotomyExpressions::compare7 @ bci:2
TestTrichotomyExpressions::testEqual7 @ bci:2
35 If === 5 34 [[ 36 37 ]] P=0.666667, C=98484.000000 !jvms:
TestTrichotomyExpressions::compare7 @ bci:2 TestTrichotomyExpressions::testEqual7 @ bci:2
44 If === 36 43 [[ 45 46 ]] P=0.500000, C=65656.000000 !jvms:
TestTrichotomyExpressions::compare7 @ bci:11 TestTrichotomyExpressions::testEqual7 @ bci:2
51 ConI === 0 [[ 71 ]] #int:1
40 ConI === 0 [[ 71 71 ]] #int:0
3 Start === 3 0 [[ 3 5 6 7 8 9 10 11 ]] #{0:control, 1:abIO, 2:memory, 3:rawptr:BotPTR,
4:return_address, 5:int, 6:int}
37 IfFalse === 35 [[ 41 ]] #0 !jvms: TestTrichotomyExpressions::compare7 @ bci:2
TestTrichotomyExpressions::testEqual7 @ bci:2
45 IfTrue === 44 [[ 41 ]] #1 !jvms: TestTrichotomyExpressions::compare7 @ bci:11
TestTrichotomyExpressions::testEqual7 @ bci:2
46 IfFalse === 44 [[ 41 ]] #0 !jvms: TestTrichotomyExpressions::compare7 @ bci:11
TestTrichotomyExpressions::testEqual7 @ bci:2
71 Phi === 41 40 40 51 [[ 65 ]] #bool !orig=[63] !jvms: TestTrichotomyExpressions::testEqual7
@ bci:13
9 Parm === 3 [[ 65 ]] ReturnAdr !jvms: TestTrichotomyExpressions::testEqual7 @ bci:-1
8 Parm === 3 [[ 65 ]] FramePtr !jvms: TestTrichotomyExpressions::testEqual7 @ bci:-1
7 Parm === 3 [[ 65 ]] Memory Memory: @BotPTR *+bot, idx=Bot; !jvms:
TestTrichotomyExpressions::testEqual7 @ bci:-1
6 Parm === 3 [[ 65 ]] I_O !jvms: TestTrichotomyExpressions::testEqual7 @ bci:-1
41 Region === 41 46 45 37 [[ 41 65 71 ]] !jvms: TestTrichotomyExpressions::compare7 @
bci:19 TestTrichotomyExpressions::testEqual7 @ bci:2
65 Return === 41 6 7 8 9 returns 71 [[ 0 ]]
More information about the hotspot-compiler-dev
mailing list