[clang] [llvm] [RISC-V] Add support for MIPS P8700 CPU (PR #117865)

Djordje Todorovic via cfe-commits cfe-commits at lists.llvm.org
Wed Nov 27 09:04:10 PST 2024


================
@@ -0,0 +1,158 @@
+//===----------------------- RISCVRemoveBackToBackBranches.cpp ------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "RISCV.h"
+#include "RISCVInstrInfo.h"
+#include "RISCVSubtarget.h"
+#include "llvm/ADT/Statistic.h"
+#include "llvm/ADT/StringRef.h"
+#include "llvm/CodeGen/MachineBasicBlock.h"
+#include "llvm/CodeGen/MachineFunction.h"
+#include "llvm/CodeGen/MachineFunctionPass.h"
+#include "llvm/CodeGen/MachineInstr.h"
+#include "llvm/CodeGen/TargetSubtargetInfo.h"
+#include "llvm/Target/TargetMachine.h"
+
+using namespace llvm;
+
+#define DEBUG_TYPE "riscv-remove-back-to-back-branches"
+
+STATISTIC(NumInsertedAligments, "Number of aligments set");
+
+namespace {
+
+// According to the MIPS specification, there shouldn't be two conditional
+// branches in the same 8-byte aligned region of code.
----------------
djtodoro wrote:

I will move this into a separate PR commit.
After reviewing what I wrote earlier, I now understand what 'work correctly' means in this context. Functionally, the core will operate correctly, but this change could impact performance. Specifically, if two branches share the same predictor index, this feature would come into play. However, this change primarily addresses an older RTL issue, so it is not strictly necessary and can be omitted or kept as off by default. Apologies for any confusion caused.

https://github.com/llvm/llvm-project/pull/117865


More information about the cfe-commits mailing list