[llvm] 0248725 - [RISCV] Correct Branch Range (#142705)
via llvm-commits
llvm-commits at lists.llvm.org
Wed Jun 4 08:35:44 PDT 2025
Author: Sam Elliott
Date: 2025-06-04T08:35:40-07:00
New Revision: 0248725699cb639fc816acfc3e34d0a7dbf59329
URL: https://github.com/llvm/llvm-project/commit/0248725699cb639fc816acfc3e34d0a7dbf59329
DIFF: https://github.com/llvm/llvm-project/commit/0248725699cb639fc816acfc3e34d0a7dbf59329.diff
LOG: [RISCV] Correct Branch Range (#142705)
This aligns the code with the other cases, which take into account the
min/max range of `isShiftedInt<N, 1>`. Given IALIGN is always 16 or 32
(bits), this should not make a difference to anything valid.
Added:
Modified:
llvm/lib/Target/RISCV/MCTargetDesc/RISCVAsmBackend.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Target/RISCV/MCTargetDesc/RISCVAsmBackend.cpp b/llvm/lib/Target/RISCV/MCTargetDesc/RISCVAsmBackend.cpp
index 44b1a83c5c17c..424c3fe5f829f 100644
--- a/llvm/lib/Target/RISCV/MCTargetDesc/RISCVAsmBackend.cpp
+++ b/llvm/lib/Target/RISCV/MCTargetDesc/RISCVAsmBackend.cpp
@@ -134,8 +134,8 @@ bool RISCVAsmBackend::fixupNeedsRelaxationAdvanced(const MCFixup &Fixup,
case RISCV::fixup_riscv_branch:
case RISCV::fixup_riscv_qc_e_branch:
// For conditional branch instructions the immediate must be
- // in the range [-4096, 4095].
- return !isInt<13>(Offset);
+ // in the range [-4096, 4094].
+ return Offset > 4094 || Offset < -4096;
}
}
More information about the llvm-commits
mailing list