summaryrefslogtreecommitdiff
path: root/compiler/optimizing/instruction_simplifier_shared.cc
diff options
context:
space:
mode:
author Anton Romanov <anton.romanov@syntacore.com> 2024-09-11 16:29:10 +0000
committer Treehugger Robot <android-test-infra-autosubmit@system.gserviceaccount.com> 2024-09-13 09:28:01 +0000
commitd0bc68e1f40259230329e6709c72af187f72144c (patch)
tree0fbe11c2b48441b1b40d598883611ece8148352d /compiler/optimizing/instruction_simplifier_shared.cc
parentd0929a5662cf29440667e40fadcf839e5fb8aa45 (diff)
riscv64: Add node Rol, fix InstructionBuilder
This reverts commit 744830cb242c82c4637e6fb303b36d0371c84979. Reason for revert: updated CHECKer test to use rolw instead of rol. Change-Id: I50e34c6ac69488a9c083f04c6382df4302e8e7d3
Diffstat (limited to 'compiler/optimizing/instruction_simplifier_shared.cc')
-rw-r--r--compiler/optimizing/instruction_simplifier_shared.cc19
1 files changed, 19 insertions, 0 deletions
diff --git a/compiler/optimizing/instruction_simplifier_shared.cc b/compiler/optimizing/instruction_simplifier_shared.cc
index b7d76da548..7f575c0348 100644
--- a/compiler/optimizing/instruction_simplifier_shared.cc
+++ b/compiler/optimizing/instruction_simplifier_shared.cc
@@ -316,4 +316,23 @@ bool TryReplaceSubSubWithSubAdd(HSub* last_sub) {
}
}
+void UnfoldRotateLeft(HRol* rol) {
+ HBasicBlock* block = rol->GetBlock();
+ HGraph* graph = block->GetGraph();
+ ArenaAllocator* allocator = graph->GetAllocator();
+ HRor* ror;
+
+ if (rol->GetRight()->IsConstant()) {
+ int32_t value = rol->GetRight()->AsIntConstant()->GetValue();
+ HIntConstant* negated = graph->GetIntConstant(-value);
+ ror = new (allocator) HRor(rol->GetType(), rol->GetLeft(), negated);
+ } else {
+ HNeg* neg = new (allocator) HNeg(DataType::Type::kInt32, rol->GetRight());
+ block->InsertInstructionBefore(neg, rol);
+ ror = new (allocator) HRor(rol->GetType(), rol->GetLeft(), neg);
+ }
+
+ block->ReplaceAndRemoveInstructionWith(rol, ror);
+}
+
} // namespace art