Skip to content

Commit c1075d5

Browse files
committed
Combine bu2i comparison optimization in z/codegen
The z/codegen skips evaluation of a comparison operation if the first OR second child is a bu2i node and its grandchild is a bloadi. This condition needs to be modified from OR to AND (i.e so that both children of the comparison operation satisfy all conditions). This fixes a bug where the second comparison child has an incompatible type with the bu2i node. Fixes: eclipse-openj9/openj9#22835 Signed-off-by: Dhruv Chopra <Dhruv.C.Chopra@ibm.com>
1 parent 0d43ebb commit c1075d5

File tree

1 file changed

+8
-11
lines changed

1 file changed

+8
-11
lines changed

compiler/z/codegen/BinaryCommutativeAnalyser.cpp

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -163,22 +163,19 @@ void TR_S390BinaryCommutativeAnalyser::genericAnalyser(TR::Node *root, TR::InstO
163163
bool adjustDiplacementOnSecondChild = false;
164164

165165
if (root->getOpCode().isBooleanCompare() || nonClobberingDestination) {
166-
if (firstChild->getOpCodeValue() == TR::bu2i && firstChild->getReferenceCount() == 1
167-
&& firstChild->getRegister() == NULL
168-
&& (firstChild->getFirstChild()->getOpCodeValue() == TR::bload
169-
|| firstChild->getFirstChild()->getOpCodeValue() == TR::bloadi)) {
166+
if ((firstChild->getOpCodeValue() == TR::bu2i && firstChild->getReferenceCount() == 1
167+
&& firstChild->getRegister() == NULL
168+
&& (firstChild->getFirstChild()->getOpCodeValue() == TR::bload
169+
|| firstChild->getFirstChild()->getOpCodeValue() == TR::bloadi))
170+
&& (secondChild->getOpCodeValue() == TR::bu2i && secondChild->getReferenceCount() == 1
171+
&& secondChild->getRegister() == NULL
172+
&& (secondChild->getFirstChild()->getOpCodeValue() == TR::bload
173+
|| secondChild->getFirstChild()->getOpCodeValue() == TR::bloadi))) {
170174
initFirstChild = firstChild;
171-
172175
firstChild = firstChild->getFirstChild();
173176
cg()->evaluate(firstChild);
174-
}
175177

176-
if (secondChild->getOpCodeValue() == TR::bu2i && secondChild->getReferenceCount() == 1
177-
&& secondChild->getRegister() == NULL
178-
&& (secondChild->getFirstChild()->getOpCodeValue() == TR::bload
179-
|| secondChild->getFirstChild()->getOpCodeValue() == TR::bloadi)) {
180178
initSecondChild = secondChild;
181-
182179
secondChild = secondChild->getFirstChild();
183180
cg()->evaluate(secondChild);
184181
}

0 commit comments

Comments
 (0)