RFR: 8284742: x86: Handle integral division overflow during parsing

Quan Anh Mai duke at openjdk.java.net
Thu Apr 14 13:09:26 UTC 2022


On Thu, 14 Apr 2022 11:57:48 GMT, Jatin Bhateja <jbhateja at openjdk.org> wrote:

>>> @jatin-bhateja Thanks a lot for your suggestions. The transformation manipulates the control flow so it should be handled during parsing since the control edge may have been lost right after that. The same goes for UDivL and UDivI intrinsic, too. I believe having target specific parsing is beneficial since we can decompose complex operations into more elemental ones, utilizing the power of the compiler more efficiently.
>>> 
>>> Delaying the handling till code emission time may miss the opportunities to hoist out the check and in the worst case would result in suboptimal code layout since the compiler can move the uncommon path out of the common path while the assembler can't.
>> 
>> Thanks I get your point, creating a control flow later may not be possible unless an explicit control projection is added to  DivI/L node during initial parsing which gets tied to its successors, and later on the IR node itself can be replaced by a control structure which converge at original control projection.  We can save redundant duplications of byte code processing and a later stage can do target lowering.
>
>> @jatin-bhateja The div nodes themselves are constructed with control input, it is the `Ideal` method that may remove this input. Post parse transformation does not only need to replace the div node with the control structure, but also has to restructure the control flow itself, so I think it would be much more complex to do so.
>> 
>> Thank you very much.
> 
> Hi @merykitty , Yes, input controlling edge cannot be used independently to create a control flow, we also need to have knowledge of next control region to create a conditional graph, thus adding an explicit output control projection from DivI/L IR nodes (which only have data flow edges) during parsing will enable creation of control flow later. Generating a control flow post parsing is not new we do it during macro expansion currently.

@jatin-bhateja  Thank you very much for the explanations, I think I will go with this approach because it is much simpler. For your concern regarding the expansions of intrinsic nodes, I think we could have another arch-dependent parsing of intrinsic if it is needed, which has the benefits of being more general since intrinsic is often expanded into multiple nodes. By the way, `UDiv` and `UMod` do not need target lowering since unsigned division cannot overflow.

@TheRealMDoerr Thanks a lot for noticing those, I have fixed them in the recent commit. And I think another PR would be more appropriate.

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

PR: https://git.openjdk.java.net/jdk/pull/8206


More information about the hotspot-compiler-dev mailing list