RFR: 8254369: Node::disconnect_inputs may skip precedences [v3]

Xin Liu xliu at openjdk.java.net
Thu Oct 15 22:46:17 UTC 2020


On Thu, 15 Oct 2020 18:19:42 GMT, Vladimir Kozlov <kvn at openjdk.org> wrote:

>> I think you could write it like this to hoist the `i < len()` test from the loop while avoiding issues when `len()` or
>> `req()` is 0:
>> uint i = len();
>> if (i > 0) {
>>   while(i > req()) {
>>     rm_prec(--i);
>>   }
>> }
>
> Nice suggestion!

> "where's the if(len() > 0)" I thought for a second, but you're right: len() >= req(), so if len() is 0, then req() must
> be 0, too, which means len() > req() is false and we won't accidentally call rm_prec(UINT_MAX)

Yes, that's why I think it's safe to save if (i > 0).

Actually, I tried to hoist some corner cases out of loop before, but that made code less straightforward.
I give it up because I don't want to win some "performance" at expense of readability and gcc/llvm can do job anyway.

Your code rm_prec(--i) is brilliant. thanks! let's see the result.

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

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


More information about the hotspot-compiler-dev mailing list