Skip to content

Commit

Permalink
8263972: C2: LoadVector/StoreVector type mismatch in MemNode::can_see…
Browse files Browse the repository at this point in the history
…_stored_value()

Reviewed-by: kvn, thartmann
  • Loading branch information
Vladimir Ivanov committed Apr 27, 2021
1 parent 377b346 commit b2628d1
Show file tree
Hide file tree
Showing 2 changed files with 82 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/hotspot/share/opto/memnode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
#include "opto/phaseX.hpp"
#include "opto/regmask.hpp"
#include "opto/rootnode.hpp"
#include "opto/vectornode.hpp"
#include "utilities/align.hpp"
#include "utilities/copy.hpp"
#include "utilities/macros.hpp"
Expand Down Expand Up @@ -1128,8 +1129,17 @@ Node* MemNode::can_see_stored_value(Node* st, PhaseTransform* phase) const {
// Thus, we are able to replace L by V.
}
// Now prove that we have a LoadQ matched to a StoreQ, for some Q.
if (store_Opcode() != st->Opcode())
if (store_Opcode() != st->Opcode()) {
return NULL;
}
// LoadVector/StoreVector needs additional check to ensure the types match.
if (store_Opcode() == Op_StoreVector) {
const TypeVect* in_vt = st->as_StoreVector()->vect_type();
const TypeVect* out_vt = as_LoadVector()->vect_type();
if (in_vt != out_vt) {
return NULL;
}
}
return st->in(MemNode::ValueIn);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
/*
* 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.vectorization;

/**
* @test
* @bug 8263972
* @requires vm.compiler2.enabled & vm.compMode != "Xint"
*
* @run main/othervm -Xcomp -XX:-TieredCompilation -XX:CompileCommand=quiet -XX:CompileCommand=compileonly,*TestMemoryVectorMismatched::test compiler.vectorization.TestMemoryVectorMismatched
*/
public class TestMemoryVectorMismatched {
public static void main(String[] g) {
int a = 400;
long expected = -35984L;
for (int i = 0; i < 10; i++) {
long v = test(a);
if (v != expected) {
throw new AssertionError("Wrong result: " + v + " != " + expected);
}
}
}

static long test(int a) {
int i16, d = 5, e = -56973;
long f[] = new long[a];
init(f, 5);
for (i16 = 2; i16 < 92; i16++) {
f[i16 - 1] *= d;
f[i16 + 1] *= d;
}
while (++e < 0) {
}
return checkSum(f);
}

public static void init(long[] a, long seed) {
for (int j = 0; j < a.length; j++) {
a[j] = (j % 2 == 0) ? seed + j : seed - j;
}
}


public static long checkSum(long[] a) {
long sum = 0;
for (int j = 0; j < a.length; j++) {
sum += (a[j] / (j + 1) + a[j] % (j + 1));
}
return sum;
}
}

1 comment on commit b2628d1

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

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

Please sign in to comment.