diff options
author | 2024-09-11 16:29:10 +0000 | |
---|---|---|
committer | 2024-09-13 09:28:01 +0000 | |
commit | d0bc68e1f40259230329e6709c72af187f72144c (patch) | |
tree | 0fbe11c2b48441b1b40d598883611ece8148352d /compiler/optimizing/instruction_simplifier_x86.cc | |
parent | d0929a5662cf29440667e40fadcf839e5fb8aa45 (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_x86.cc')
-rw-r--r-- | compiler/optimizing/instruction_simplifier_x86.cc | 31 |
1 files changed, 26 insertions, 5 deletions
diff --git a/compiler/optimizing/instruction_simplifier_x86.cc b/compiler/optimizing/instruction_simplifier_x86.cc index 5a4345d589..e1c783e5b8 100644 --- a/compiler/optimizing/instruction_simplifier_x86.cc +++ b/compiler/optimizing/instruction_simplifier_x86.cc @@ -48,6 +48,7 @@ class InstructionSimplifierX86Visitor final : public HGraphVisitor { } void VisitAnd(HAnd * instruction) override; + void VisitRol(HRol* instruction) override; void VisitXor(HXor* instruction) override; private: @@ -57,6 +58,10 @@ class InstructionSimplifierX86Visitor final : public HGraphVisitor { void InstructionSimplifierX86Visitor::VisitAnd(HAnd* instruction) { + if (!HasAVX2()) { + return; + } + if (TryCombineAndNot(instruction)) { RecordSimplification(); } else if (instruction->GetResultType() == DataType::Type::kInt32) { @@ -66,7 +71,26 @@ void InstructionSimplifierX86Visitor::VisitAnd(HAnd* instruction) { } } +void InstructionSimplifierX86Visitor::VisitRol(HRol* rol) { + if (rol->GetType() != DataType::Type::kInt64) { + return; + } + + HBasicBlock* block = rol->GetBlock(); + HGraph* graph = block->GetGraph(); + ArenaAllocator* allocator = graph->GetAllocator(); + + HNeg* neg = new (allocator) HNeg(DataType::Type::kInt32, rol->GetRight()); + block->InsertInstructionBefore(neg, rol); + HRor* ror = new (allocator) HRor(rol->GetType(), rol->GetLeft(), neg); + block->ReplaceAndRemoveInstructionWith(rol, ror); +} + void InstructionSimplifierX86Visitor::VisitXor(HXor* instruction) { + if (!HasAVX2()) { + return; + } + if (instruction->GetResultType() == DataType::Type::kInt32) { if (TryGenerateMaskUptoLeastSetBit(instruction)) { RecordSimplification(); @@ -76,11 +100,8 @@ void InstructionSimplifierX86Visitor::VisitXor(HXor* instruction) { bool InstructionSimplifierX86::Run() { InstructionSimplifierX86Visitor visitor(graph_, codegen_, stats_); - if (visitor.HasAVX2()) { - visitor.VisitReversePostOrder(); - return true; - } - return false; + visitor.VisitReversePostOrder(); + return true; } } // namespace x86 |