RFR: 8273454: C2: Transform (-a)*(-b) into a*b [v4]
Zhengyu Gu
zgu at openjdk.java.net
Wed Sep 15 15:55:52 UTC 2021
On Tue, 14 Sep 2021 07:05:40 GMT, Tobias Hartmann <thartmann at openjdk.org> wrote:
>> Zhengyu Gu has updated the pull request incrementally with one additional commit since the last revision:
>>
>> Fix node in place instead of creating new node
>
> test/hotspot/jtreg/compiler/integerArithmetic/TestNegMultiply.java line 45:
>
>> 43: private static void testInt(int a, int b) {
>> 44: int expected = (-a) * (-b);
>> 45: for (int i = 0; i < 20_000; i++) {
>
> Why do you need a second loop in here? It's sufficient to set `TEST_COUNT` high enough to trigger compilation. I would suggest something like this:
>
>
> private static int testInt(int a, int b) {
> return (-a) * (-b);
> }
>
> private static void runIntTests() {
> for (int i = 0; i < TEST_COUNT; i++) {
> int a = random.nextInt();
> int b = random.nextInt();
> int res = testInt(a, b);
> Asserts.assertEQ(a * b, res);
> }
> }
>
>
> And then run with `-XX:CompileCommand=dontinline,TestNegMultiply::test*`. No need to disable OnStackReplacement.
The inner loop ensures that all tests hit JIT-ed version. If the transformation is broken, I would prefer the test fails for the very first iteration, instead of somewhere in the middle.
I refactored the code to remove inner loop.
Also, fixed command option.
-------------
PR: https://git.openjdk.java.net/jdk/pull/5403
More information about the hotspot-compiler-dev
mailing list