8375633: C2: Missed Ideal optimization opportunity with ConvD2F/ConvF2HF and -XX:+StressIncrementalInlining#29570
8375633: C2: Missed Ideal optimization opportunity with ConvD2F/ConvF2HF and -XX:+StressIncrementalInlining#29570krk wants to merge 2 commits intoopenjdk:masterfrom
Conversation
…2HF and -XX:+StressIncrementalInlining
|
👋 Welcome back krk! A progress list of the required criteria for merging this PR into |
|
❗ This change is not yet ready to be integrated. |
Webrevs
|
|
Thanks for working on this. I'm still seeing some "Missed Ideal optimization opportunity in PhaseIterGVN for ConvF2HF" in testing, for instance on
both with flags If I understand well, I don't think your fix should check jdk/src/hotspot/share/opto/phaseX.cpp Lines 2166 to 2255 in 1ac9658 As far as I know, there is no way to see the new node from I think if you remove the declaration of |
src/hotspot/share/opto/phaseX.cpp
Outdated
| // ConvD2F::Ideal matches ConvD2F(SqrtD(ConvF2D(x))) => SqrtF(x). | ||
| // ConvF2HF::Ideal matches ConvF2HF(binopF(ConvHF2F(...))) => FP16BinOp(...). | ||
| // Notify them when the inner conversion changes. | ||
| int n_op = n->Opcode(); |
There was a problem hiding this comment.
@marc-chevalier is right, you should not use the opcode of n directly. Node n may be a node that is about to get replaced, so might run into false negatives. I made this mistake in the past, see this PR
benoitmaillard
left a comment
There was a problem hiding this comment.
Thank you for working on this. In addition to my comment on using the opcode of n, I think this PR needs a regression test that (ideally) covers each pattern added in add_users_of_node_to_worklist.
|
Thank you for the insightful comments, fixed the |
ConvD2FNodeandConvF2HFNode::Idealalready optimize depth-2 patterns (e.g.ConvD2F(SqrtD(ConvF2D(x))) → SqrtF(x)), but withStressIncrementalInlining, the inner conversion may be inlined after IGVN has already visited the outer one.The intermediate node (
SqrtD) doesn't propagate the change to its users, so the optimization is missed.The fix adds worklist propagation rules in
add_users_of_use_to_worklist, when aConvF2Dnode changes and its user isSqrtD, push ConvD2F users of thatSqrtDonto the worklist. Similarly, whenConvHF2Fchanges and its user is a float binary op, pushConvF2HFusers.The intermediate node checks (
SqrtD,is_float32_binary_oper) match exactly what the currentIdealmethods look for.Progress
Issue
Reviewing
Using
gitCheckout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/29570/head:pull/29570$ git checkout pull/29570Update a local copy of the PR:
$ git checkout pull/29570$ git pull https://git.openjdk.org/jdk.git pull/29570/headUsing Skara CLI tools
Checkout this PR locally:
$ git pr checkout 29570View PR using the GUI difftool:
$ git pr show -t 29570Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/29570.diff
Using Webrev
Link to Webrev Comment