From 66349e279eb284332c9267b2a12333f562951974 Mon Sep 17 00:00:00 2001 From: Sam Elliott Date: Tue, 3 Jun 2025 17:33:46 -0700 Subject: [PATCH] [RISCV] Correct Branch Range This aligns the code with the other cases, which take into account the min/max range of `isShiftedInt`. Given IALIGN is always 16 or 32 (bits), this should not make a difference to anything valid. --- llvm/lib/Target/RISCV/MCTargetDesc/RISCVAsmBackend.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/llvm/lib/Target/RISCV/MCTargetDesc/RISCVAsmBackend.cpp b/llvm/lib/Target/RISCV/MCTargetDesc/RISCVAsmBackend.cpp index 963501db118e7..cd527f188a284 100644 --- a/llvm/lib/Target/RISCV/MCTargetDesc/RISCVAsmBackend.cpp +++ b/llvm/lib/Target/RISCV/MCTargetDesc/RISCVAsmBackend.cpp @@ -133,8 +133,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; } }