diff options
| author | 2024-05-30 17:05:54 +0500 | |
|---|---|---|
| committer | 2024-06-12 10:42:45 +0000 | |
| commit | b658a268e2e76e429702c2929d24ebbbf909e947 (patch) | |
| tree | 2366f34aecd290dcc988dbb3d1923e9471d8370e /compiler/optimizing/nodes_shared.h | |
| parent | 05e428dacb0b4877960e3b1c0d50cb9c90f378d5 (diff) | |
riscv: Expand BitwiseNegatedRight to riscv64, optimize
Add BitwiseNegatedRight optimization for riscv:
And + Not -> AndNot
Or + Not -> OrNot
Xor + Not -> XorNot
By compiling facebook app using dex2oat I got:
169 cases of And + Not pattern
9 cases of Or + Not pattern
1 case of Xor + Not pattern.
Test: art/test/testrunner/testrunner.py --target --64 --ndebug --optimizing
Change-Id: Icc2db96770378005d2fb01176298a067e1a0e4ad
Diffstat (limited to 'compiler/optimizing/nodes_shared.h')
| -rw-r--r-- | compiler/optimizing/nodes_shared.h | 70 |
1 files changed, 0 insertions, 70 deletions
diff --git a/compiler/optimizing/nodes_shared.h b/compiler/optimizing/nodes_shared.h index d627c6daee..abb9f959c0 100644 --- a/compiler/optimizing/nodes_shared.h +++ b/compiler/optimizing/nodes_shared.h @@ -62,76 +62,6 @@ class HMultiplyAccumulate final : public HExpression<3> { const InstructionKind op_kind_; }; -class HBitwiseNegatedRight final : public HBinaryOperation { - public: - HBitwiseNegatedRight(DataType::Type result_type, - InstructionKind op, - HInstruction* left, - HInstruction* right, - uint32_t dex_pc = kNoDexPc) - : HBinaryOperation(kBitwiseNegatedRight, - result_type, - left, - right, - SideEffects::None(), - dex_pc), - op_kind_(op) { - DCHECK(op == HInstruction::kAnd || op == HInstruction::kOr || op == HInstruction::kXor) << op; - } - - template <typename T, typename U> - auto Compute(T x, U y) const -> decltype(x & ~y) { - static_assert(std::is_same<decltype(x & ~y), decltype(x | ~y)>::value && - std::is_same<decltype(x & ~y), decltype(x ^ ~y)>::value, - "Inconsistent negated bitwise types"); - switch (op_kind_) { - case HInstruction::kAnd: - return x & ~y; - case HInstruction::kOr: - return x | ~y; - case HInstruction::kXor: - return x ^ ~y; - default: - LOG(FATAL) << "Unreachable"; - UNREACHABLE(); - } - } - - bool InstructionDataEquals(const HInstruction* other) const override { - return op_kind_ == other->AsBitwiseNegatedRight()->op_kind_; - } - - HConstant* Evaluate(HIntConstant* x, HIntConstant* y) const override { - return GetBlock()->GetGraph()->GetIntConstant( - Compute(x->GetValue(), y->GetValue()), GetDexPc()); - } - HConstant* Evaluate(HLongConstant* x, HLongConstant* y) const override { - return GetBlock()->GetGraph()->GetLongConstant( - Compute(x->GetValue(), y->GetValue()), GetDexPc()); - } - HConstant* Evaluate([[maybe_unused]] HFloatConstant* x, - [[maybe_unused]] HFloatConstant* y) const override { - LOG(FATAL) << DebugName() << " is not defined for float values"; - UNREACHABLE(); - } - HConstant* Evaluate([[maybe_unused]] HDoubleConstant* x, - [[maybe_unused]] HDoubleConstant* y) const override { - LOG(FATAL) << DebugName() << " is not defined for double values"; - UNREACHABLE(); - } - - InstructionKind GetOpKind() const { return op_kind_; } - - DECLARE_INSTRUCTION(BitwiseNegatedRight); - - protected: - DEFAULT_COPY_CONSTRUCTOR(BitwiseNegatedRight); - - private: - // Specifies the bitwise operation, which will be then negated. - const InstructionKind op_kind_; -}; - // This instruction computes part of the array access offset (data and index offset). // // For array accesses the element address has the following structure: |