From a62b60bc009d6cd94eb498b3219090e39e495a8e Mon Sep 17 00:00:00 2001 From: Henry Zongaro Date: Fri, 3 May 2024 14:48:26 -0700 Subject: [PATCH] Use testIsClassArrayType to generate IL to test for array type The downstream OpenJ9 project defines a new method, TR_VMBase::testIsClassArrayType, that generates IL to tests whether a class is an array class. Change code that generated IL that loaded classDepthAndFlags field itself to call testIsClassArrayType instead to hide at least some of the J9-specific details. Also, generate a comparison of the result of the IL produced by testIsClassArrayType with zero, rather than comparing with the array class flag. A comparison with zero is expected to be preferred on most platforms. Signed-off-by: Henry Zongaro --- compiler/optimizer/LoopVersioner.cpp | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) diff --git a/compiler/optimizer/LoopVersioner.cpp b/compiler/optimizer/LoopVersioner.cpp index 0d353d03cdd..e5aefd3c94d 100644 --- a/compiler/optimizer/LoopVersioner.cpp +++ b/compiler/optimizer/LoopVersioner.cpp @@ -8340,19 +8340,9 @@ bool TR_LoopVersioner::depsForLoopEntryPrep( TR::Node *vftLoad = TR::Node::createWithSymRef(TR::aloadi, 1, 1, node->getFirstChild(), comp()->getSymRefTab()->findOrCreateVftSymbolRef()); //TR::Node *componentTypeLoad = TR::Node::create(TR::aloadi, 1, vftLoad, comp()->getSymRefTab()->findOrCreateArrayComponentTypeSymbolRef()); - TR::Node *classFlag = NULL; - if (comp()->target().is32Bit()) - { - classFlag = TR::Node::createWithSymRef(TR::iloadi, 1, 1, vftLoad, comp()->getSymRefTab()->findOrCreateClassAndDepthFlagsSymbolRef()); - } - else - { - classFlag = TR::Node::createWithSymRef(TR::lloadi, 1, 1, vftLoad, comp()->getSymRefTab()->findOrCreateClassAndDepthFlagsSymbolRef()); - classFlag = TR::Node::create(TR::l2i, 1, classFlag); - } - TR::Node *andConstNode = TR::Node::create(classFlag, TR::iconst, 0, TR::Compiler->cls.flagValueForArrayCheck(comp())); - TR::Node * andNode = TR::Node::create(TR::iand, 2, classFlag, andConstNode); - TR::Node *cmp = TR::Node::createif(TR::ificmpne, andNode, andConstNode, _exitGotoTarget); + TR::Node *classFlag = comp()->fej9()->testIsClassArrayType(vftLoad); + TR::Node *zeroNode = TR::Node::iconst(classFlag, 0); + TR::Node *cmp = TR::Node::createif(TR::ificmpeq, classFlag, zeroNode, _exitGotoTarget); if (addLoopEntryPrepDep(LoopEntryPrep::TEST, cmp, deps, visited) == NULL) { dumpOptDetailsFailedToCreateTest("array type", node->getFirstChild());