8343067: C2: revisit constant-offset AddP chains after successful input idealizations
Reviewed-by: kvn, vlivanov
This commit is contained in:
parent
5ca6698ba4
commit
ec13364cda
@ -27,6 +27,7 @@
|
||||
#include "gc/shared/c2/barrierSetC2.hpp"
|
||||
#include "memory/allocation.inline.hpp"
|
||||
#include "memory/resourceArea.hpp"
|
||||
#include "opto/addnode.hpp"
|
||||
#include "opto/block.hpp"
|
||||
#include "opto/callnode.hpp"
|
||||
#include "opto/castnode.hpp"
|
||||
@ -1634,12 +1635,19 @@ void PhaseIterGVN::add_users_of_use_to_worklist(Node* n, Node* use, Unique_Node_
|
||||
}
|
||||
}
|
||||
}
|
||||
// If changed AddP inputs, check Stores for loop invariant
|
||||
if( use_op == Op_AddP ) {
|
||||
// If changed AddP inputs:
|
||||
// - check Stores for loop invariant, and
|
||||
// - if the changed input is the offset, check constant-offset AddP users for
|
||||
// address expression flattening.
|
||||
if (use_op == Op_AddP) {
|
||||
bool offset_changed = n == use->in(AddPNode::Offset);
|
||||
for (DUIterator_Fast i2max, i2 = use->fast_outs(i2max); i2 < i2max; i2++) {
|
||||
Node* u = use->fast_out(i2);
|
||||
if (u->is_Mem())
|
||||
if (u->is_Mem()) {
|
||||
worklist.push(u);
|
||||
} else if (offset_changed && u->is_AddP() && u->in(AddPNode::Offset)->is_Con()) {
|
||||
worklist.push(u);
|
||||
}
|
||||
}
|
||||
}
|
||||
// If changed initialization activity, check dependent Stores
|
||||
|
@ -0,0 +1,56 @@
|
||||
/*
|
||||
* Copyright (c) 2024, 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.c2.irTests.igvn;
|
||||
|
||||
import compiler.lib.ir_framework.*;
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @bug 8343067
|
||||
* @requires os.simpleArch == "x64" | os.simpleArch == "aarch64"
|
||||
* @requires vm.compiler2.enabled
|
||||
* @summary Test that chains of AddP nodes with constant offsets are idealized
|
||||
* when their offset input changes.
|
||||
* @library /test/lib /
|
||||
* @run driver compiler.c2.irTests.igvn.TestCombineAddPWithConstantOffsets
|
||||
*/
|
||||
public class TestCombineAddPWithConstantOffsets {
|
||||
|
||||
public static void main(String[] args) {
|
||||
TestFramework.run();
|
||||
}
|
||||
|
||||
@Test
|
||||
@IR(applyIfPlatform = {"x64", "true"}, failOn = {IRNode.ADD_P_OF, ".*"})
|
||||
@IR(applyIfPlatform = {"aarch64", "true"}, failOn = {IRNode.ADD_P_OF, "reg_imm"})
|
||||
static void testCombineAddPWithConstantOffsets(int[] arr) {
|
||||
for (long i = 6; i < 14; i++) {
|
||||
arr[(int)i] = 1;
|
||||
}
|
||||
}
|
||||
|
||||
@Run(test = {"testCombineAddPWithConstantOffsets"})
|
||||
public void runTests() {
|
||||
testCombineAddPWithConstantOffsets(new int[14]);
|
||||
}
|
||||
}
|
@ -279,6 +279,12 @@ public class IRNode {
|
||||
superWordNodes(ADD_REDUCTION_VL, "AddReductionVL");
|
||||
}
|
||||
|
||||
public static final String ADD_P_OF = COMPOSITE_PREFIX + "ADD_P_OF" + POSTFIX;
|
||||
static {
|
||||
String regex = START + "addP_" + IS_REPLACED + MID + ".*" + END;
|
||||
machOnly(ADD_P_OF, regex);
|
||||
}
|
||||
|
||||
public static final String ALLOC = PREFIX + "ALLOC" + POSTFIX;
|
||||
static {
|
||||
String optoRegex = "(.*precise .*\\R((.*(?i:mov|mv|xorl|nop|spill).*|\\s*)\\R)*.*(?i:call,static).*wrapper for: C2 Runtime new_instance" + END;
|
||||
|
Loading…
Reference in New Issue
Block a user