Skip to content

Commit

Permalink
AArch64: Handle shift amount 0
Browse files Browse the repository at this point in the history
This code fixes shiftHelper() in AArch64 codegen.
It generates a mov instruction when the shift amount is 0 and the
reference count of the first child of a shift node is larger than 1.

Signed-off-by: KONNO Kazuhiro <konno@jp.ibm.com>
  • Loading branch information
knn-k committed May 23, 2024
1 parent 5faa3ec commit 721d05f
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions compiler/aarch64/codegen/BinaryEvaluator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1576,9 +1576,17 @@ static TR::Register *shiftHelper(TR::Node *node, TR::ARM64ShiftCode shiftType, T
if (secondOp == TR::iconst)
{
int32_t value = secondChild->getInt();
if (value == 0 && firstChild->getReferenceCount() == 1)
if (value == 0)
{
trgReg = srcReg;
if (firstChild->getReferenceCount() == 1)
{
trgReg = srcReg;
}
else
{
trgReg = cg->allocateRegister();
generateMovInstruction(cg, node, trgReg, srcReg, is64bit);
}
}
else
{
Expand Down

0 comments on commit 721d05f

Please sign in to comment.