[llvm] [RISCV][MC] Correct the register state update for auipc (PR #130897)

Craig Topper via llvm-commits llvm-commits at lists.llvm.org
Tue Mar 11 23:53:31 PDT 2025


================
@@ -195,7 +195,7 @@ class RISCVMCInstrAnalysis : public MCInstrAnalysis {
     }
     case RISCV::AUIPC:
       setGPRState(Inst.getOperand(0).getReg(),
-                  Addr + (Inst.getOperand(1).getImm() << 12));
+                  Addr + ((int32_t)Inst.getOperand(1).getImm() << 12));
----------------
topperc wrote:

Use `Addr + SignExtend64<32>(Inst.getOperand(1).getImm() << 12))`. It's more readable.

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


More information about the llvm-commits mailing list