8378239: C2: Incorrect check in StoreNode::Identity

Reviewed-by: epeter, rcastanedalo
This commit is contained in:
Quan Anh Mai 2026-02-26 11:22:43 +00:00
parent 4a08996147
commit 00064ee773
2 changed files with 15 additions and 4 deletions

View File

@ -3567,8 +3567,11 @@ Node* StoreNode::Identity(PhaseGVN* phase) {
val->in(MemNode::Address)->eqv_uncast(adr) &&
val->in(MemNode::Memory )->eqv_uncast(mem) &&
val->as_Load()->store_Opcode() == Opcode()) {
// Ensure vector type is the same
if (!is_StoreVector() || (mem->is_LoadVector() && as_StoreVector()->vect_type() == mem->as_LoadVector()->vect_type())) {
if (!is_StoreVector()) {
result = mem;
} else if (Opcode() == Op_StoreVector && val->Opcode() == Op_LoadVector &&
as_StoreVector()->vect_type() == val->as_LoadVector()->vect_type()) {
// Ensure both are not masked accesses or gathers/scatters and vector types are the same
result = mem;
}
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2025, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
* Copyright (c) 2025, 2026, NVIDIA CORPORATION & 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
@ -29,7 +29,7 @@ import jdk.incubator.vector.*;
import jdk.test.lib.Asserts;
/**
* @test 8371603
* @test 8371603 8378239
* @key randomness
* @library /test/lib /
* @summary Test the missing optimization issues for vector load/store caused by JDK-8286941
@ -96,6 +96,14 @@ public class TestVectorLoadStoreOptimization {
}
}
// Test that store a value that is just loaded from the same memory location is elided
@Test
@IR(failOn = IRNode.STORE_VECTOR,
applyIfCPUFeatureOr = {"asimd", "true", "avx", "true", "rvv", "true"})
public static void testStoreVector2() {
IntVector.fromArray(SPECIES, a, 0).intoArray(a, 0);
}
public static void main(String[] args) {
TestFramework testFramework = new TestFramework();
testFramework.setDefaultWarmup(10000)