Skip to content

Commit

Permalink
8275643: C2's unaryOp vector intrinsic does not properly handle LongV…
Browse files Browse the repository at this point in the history
…ector.neg

Reviewed-by: chagedorn, sviswanathan
  • Loading branch information
TobiHartmann committed Nov 19, 2021
1 parent 2f0bde1 commit 47564ca
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/hotspot/share/prims/vectorSupport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,7 @@ int VectorSupport::vop2ideal(jint id, BasicType bt) {
case T_BYTE: // fall-through
case T_SHORT: // fall-through
case T_INT: return Op_NegI;
case T_LONG: return Op_NegL;
case T_FLOAT: return Op_NegF;
case T_DOUBLE: return Op_NegD;
default: fatal("NEG: %s", type2name(bt));
Expand Down
50 changes: 50 additions & 0 deletions test/hotspot/jtreg/compiler/vectorapi/TestLongVectorNeg.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/*
* Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/

package compiler.vectorapi;

import jdk.incubator.vector.LongVector;

/*
* @test
* @bug 8275643
* @summary Test that LongVector.neg is properly handled by the _VectorUnaryOp C2 intrinsic
* @modules jdk.incubator.vector
* @run main/othervm -XX:-TieredCompilation -XX:+AlwaysIncrementalInline -Xbatch
* -XX:CompileCommand=dontinline,compiler.vectorapi.TestLongVectorNeg::test
* compiler.vectorapi.TestLongVectorNeg
*/
public class TestLongVectorNeg {

static LongVector test(LongVector v) {
return v.neg();
}

public static void main(String[] args) {
LongVector v = LongVector.zero(LongVector.SPECIES_128);
for (int i = 0; i < 50_000; ++i) {
v.abs(); // Warmup to make sure the !VO_SPECIAL code path is taken as well
test(v);
}
}
}

3 comments on commit 47564ca

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@GoeLin
Copy link
Member

@GoeLin GoeLin commented on 47564ca Feb 1, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/backport jdk17u-dev

@openjdk
Copy link

@openjdk openjdk bot commented on 47564ca Feb 1, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@GoeLin the backport was successfully created on the branch GoeLin-backport-47564cae in my personal fork of openjdk/jdk17u-dev. To create a pull request with this backport targeting openjdk/jdk17u-dev:master, just click the following link:

➡️ Create pull request

The title of the pull request is automatically filled in correctly and below you find a suggestion for the pull request body:

Hi all,

This pull request contains a backport of commit 47564cae from the openjdk/jdk repository.

The commit being backported was authored by Tobias Hartmann on 19 Nov 2021 and was reviewed by Christian Hagedorn and Sandhya Viswanathan.

Thanks!

If you need to update the source branch of the pull then run the following commands in a local clone of your personal fork of openjdk/jdk17u-dev:

$ git fetch https://github.com/openjdk-bots/jdk17u-dev GoeLin-backport-47564cae:GoeLin-backport-47564cae
$ git checkout GoeLin-backport-47564cae
# make changes
$ git add paths/to/changed/files
$ git commit --message 'Describe additional changes made'
$ git push https://github.com/openjdk-bots/jdk17u-dev GoeLin-backport-47564cae

Please sign in to comment.