RFR(M): 8136725 Provide utility for creation a counted loop reserve copy (clone)

Civlin, Jan jan.civlin at intel.com
Fri Sep 18 17:05:29 UTC 2015


As I was working on modification of SuperWord::output - and this is a function where you modify the ideal graph on the fly and cannot exit on error - I was wondering how can I protect my algorithm in a case some wrong decision was made on the previous stage of the SuperWord but discovered only at the final stage, when the graph is already half modified.

So here is my solution: 
- the graph to be modified is cloned.
- five nodes are added: intcon(0) is disconnected, intcon(1)->If-> IfTrue->orig_loop: IfFalse->clone_loop.

Then any optimization is executed on the original loop, and if it finishes ok, nothing else need to be done, the clone_loop will be removed as dead in the consecutive stages of compiler. 
At any moment, if an error occurs, the node intcon(1) may be subsumed by node intcon(0), therefore  the clone_loop becomes "active" and the original "unfinished in modification" loop will be removed later.

This utility is implemented in class CountedLoopReserveKit.
The loop cloning and 5 nodes adding is realized in the ctor and possible subsuming intcon(1) by intcon(0) in dtor, so a simple return from the modifying graph function will do graph correction (switching in choice) of the graph.
Basically, it is sufficient the create a local object of CountedLoopReserveKit class, the scoped dtor makes the choice: modified or original loop.

SuperWord::output in this submission is included only to illustrate how to use the CountedLoopReserveKit.
The actual new SuperWord::output where CountedLoopReserveKit  is indeed substantial is coming in the next patch. 

This reserve loop cloning in SuperWord may be disabled by the global flag DoReserveCopyInSuperWord. 

-----Original Message-----
From: Igor Veresov [mailto:igor.veresov at oracle.com] 
Sent: Thursday, September 17, 2015 2:31 PM
To: hotspot compiler
Cc: Civlin, Jan
Subject: RFR(M): 8136725 Provide utility for creation a counted loop reserve copy (clone)

Provide utility for creation a counted loop reserve copy (clone).
May be used in any graph optimization for simple roll back to the original loop, in partially will be used in SuperWord, where the loop modification goes on-the-fly and potentially may not finish correctly (the patch for SuperWord is coming soon).

This is contributed by Jan Civlin <jan.civlin at intel.com>

Webrev: http://cr.openjdk.java.net/~iveresov/loop-reverse/webrev-091515/

igor



More information about the hotspot-compiler-dev mailing list