[llvm] [RISCV][Xqcili] Implement Load Immediate Support (PR #132496)
Sam Elliott via llvm-commits
llvm-commits at lists.llvm.org
Tue Mar 25 07:59:33 PDT 2025
https://github.com/lenary updated https://github.com/llvm/llvm-project/pull/132496
>From 8df25da09c0daeb77d47232ccfe45909196c2e97 Mon Sep 17 00:00:00 2001
From: Sam Elliott <quic_aelliott at quicinc.com>
Date: Fri, 21 Mar 2025 17:19:31 -0700
Subject: [PATCH 1/3] [RISCV][Xqcili] Implement Load Immediate Support
This is required to support `li`, but the code is also shared with
CodeGen so the compiler will now emit instructions from Xqcili when that
extension is enabled during compilation.
Also implemented some missed verifiers in
`RISCVInstrInfo::verifyInstruction`, some of which are required for this
change.
---
.../Target/RISCV/MCTargetDesc/RISCVMatInt.cpp | 25 ++
llvm/lib/Target/RISCV/RISCVInstrInfo.cpp | 3 +
llvm/test/CodeGen/RISCV/imm.ll | 411 ++++++++++++++++++
llvm/test/MC/RISCV/xqcili-li.s | 39 ++
4 files changed, 478 insertions(+)
create mode 100644 llvm/test/MC/RISCV/xqcili-li.s
diff --git a/llvm/lib/Target/RISCV/MCTargetDesc/RISCVMatInt.cpp b/llvm/lib/Target/RISCV/MCTargetDesc/RISCVMatInt.cpp
index e40c85abc8b5d..81f25054bf878 100644
--- a/llvm/lib/Target/RISCV/MCTargetDesc/RISCVMatInt.cpp
+++ b/llvm/lib/Target/RISCV/MCTargetDesc/RISCVMatInt.cpp
@@ -22,6 +22,10 @@ static int getInstSeqCost(RISCVMatInt::InstSeq &Res, bool HasRVC) {
// Assume instructions that aren't listed aren't compressible.
bool Compressed = false;
switch (Instr.getOpcode()) {
+ case RISCV::QC_E_LI:
+ // One 48-bit instruction takes the space of 1.5 regular instructions.
+ Cost += 150;
+ continue;
case RISCV::SLLI:
case RISCV::SRLI:
Compressed = true;
@@ -57,6 +61,25 @@ static void generateInstSeqImpl(int64_t Val, const MCSubtargetInfo &STI,
return;
}
+ if (!IsRV64 && STI.hasFeature(RISCV::FeatureVendorXqcili)) {
+ bool FitsOneStandardInst =
+ ((Val & 0xFFF) == 0) || (((Val + 0x800) & 0xFFFFF000) == 0);
+
+ // 20-bit signed immediates that don't fit into `ADDI` or `LUI` should use
+ // `QC.LI` (a single 32-bit instruction).
+ if (!FitsOneStandardInst && isInt<20>(Val)) {
+ Res.emplace_back(RISCV::QC_LI, Val);
+ return;
+ }
+
+ // 32-bit signed immediates that don't fit into `ADDI`, `LUI` or `QC.LI`
+ // should use `QC.E.LI` (a single 48-bit instruction).
+ if (!FitsOneStandardInst && isInt<32>(Val)) {
+ Res.emplace_back(RISCV::QC_E_LI, Val);
+ return;
+ }
+ }
+
if (isInt<32>(Val)) {
// Depending on the active bits in the immediate Value v, the following
// instruction sequences are emitted:
@@ -523,6 +546,8 @@ OpndKind Inst::getOpndKind() const {
default:
llvm_unreachable("Unexpected opcode!");
case RISCV::LUI:
+ case RISCV::QC_LI:
+ case RISCV::QC_E_LI:
return RISCVMatInt::Imm;
case RISCV::ADD_UW:
return RISCVMatInt::RegX0;
diff --git a/llvm/lib/Target/RISCV/RISCVInstrInfo.cpp b/llvm/lib/Target/RISCV/RISCVInstrInfo.cpp
index 62f978d64fbb9..687bf85b9031a 100644
--- a/llvm/lib/Target/RISCV/RISCVInstrInfo.cpp
+++ b/llvm/lib/Target/RISCV/RISCVInstrInfo.cpp
@@ -2603,8 +2603,11 @@ bool RISCVInstrInfo::verifyInstruction(const MachineInstr &MI,
// clang-format off
CASE_OPERAND_SIMM(5)
CASE_OPERAND_SIMM(6)
+ CASE_OPERAND_SIMM(11)
CASE_OPERAND_SIMM(12)
+ CASE_OPERAND_SIMM(20)
CASE_OPERAND_SIMM(26)
+ CASE_OPERAND_SIMM(32)
// clang-format on
case RISCVOp::OPERAND_SIMM5_PLUS1:
Ok = (isInt<5>(Imm) && Imm != -16) || Imm == 16;
diff --git a/llvm/test/CodeGen/RISCV/imm.ll b/llvm/test/CodeGen/RISCV/imm.ll
index 830f381b659d1..f324a9bc120ef 100644
--- a/llvm/test/CodeGen/RISCV/imm.ll
+++ b/llvm/test/CodeGen/RISCV/imm.ll
@@ -1,6 +1,8 @@
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
; RUN: llc -mtriple=riscv32 -riscv-disable-using-constant-pool-for-large-ints -verify-machineinstrs < %s \
; RUN: | FileCheck %s -check-prefix=RV32I
+; RUN: llc -mtriple=riscv32 -riscv-disable-using-constant-pool-for-large-ints -mattr=+experimental-xqcili \
+; RUN: -verify-machineinstrs < %s | FileCheck %s -check-prefix=RV32IXQCILI
; RUN: llc -mtriple=riscv64 -riscv-disable-using-constant-pool-for-large-ints -verify-machineinstrs < %s \
; RUN: | FileCheck %s -check-prefixes=RV64I,RV64-NOPOOL
; RUN: llc -mtriple=riscv64 -verify-machineinstrs < %s \
@@ -31,6 +33,11 @@ define signext i32 @zero() nounwind {
; RV32I-NEXT: li a0, 0
; RV32I-NEXT: ret
;
+; RV32IXQCILI-LABEL: zero:
+; RV32IXQCILI: # %bb.0:
+; RV32IXQCILI-NEXT: li a0, 0
+; RV32IXQCILI-NEXT: ret
+;
; RV64I-LABEL: zero:
; RV64I: # %bb.0:
; RV64I-NEXT: li a0, 0
@@ -74,6 +81,11 @@ define signext i32 @pos_small() nounwind {
; RV32I-NEXT: li a0, 2047
; RV32I-NEXT: ret
;
+; RV32IXQCILI-LABEL: pos_small:
+; RV32IXQCILI: # %bb.0:
+; RV32IXQCILI-NEXT: li a0, 2047
+; RV32IXQCILI-NEXT: ret
+;
; RV64I-LABEL: pos_small:
; RV64I: # %bb.0:
; RV64I-NEXT: li a0, 2047
@@ -117,6 +129,11 @@ define signext i32 @neg_small() nounwind {
; RV32I-NEXT: li a0, -2048
; RV32I-NEXT: ret
;
+; RV32IXQCILI-LABEL: neg_small:
+; RV32IXQCILI: # %bb.0:
+; RV32IXQCILI-NEXT: li a0, -2048
+; RV32IXQCILI-NEXT: ret
+;
; RV64I-LABEL: neg_small:
; RV64I: # %bb.0:
; RV64I-NEXT: li a0, -2048
@@ -161,6 +178,11 @@ define signext i32 @pos_i32() nounwind {
; RV32I-NEXT: addi a0, a0, -1297
; RV32I-NEXT: ret
;
+; RV32IXQCILI-LABEL: pos_i32:
+; RV32IXQCILI: # %bb.0:
+; RV32IXQCILI-NEXT: qc.e.li a0, 1735928559
+; RV32IXQCILI-NEXT: ret
+;
; RV64I-LABEL: pos_i32:
; RV64I: # %bb.0:
; RV64I-NEXT: lui a0, 423811
@@ -212,6 +234,11 @@ define signext i32 @neg_i32() nounwind {
; RV32I-NEXT: addi a0, a0, -273
; RV32I-NEXT: ret
;
+; RV32IXQCILI-LABEL: neg_i32:
+; RV32IXQCILI: # %bb.0:
+; RV32IXQCILI-NEXT: qc.e.li a0, -559038737
+; RV32IXQCILI-NEXT: ret
+;
; RV64I-LABEL: neg_i32:
; RV64I: # %bb.0:
; RV64I-NEXT: lui a0, 912092
@@ -262,6 +289,11 @@ define signext i32 @pos_i32_hi20_only() nounwind {
; RV32I-NEXT: lui a0, 16
; RV32I-NEXT: ret
;
+; RV32IXQCILI-LABEL: pos_i32_hi20_only:
+; RV32IXQCILI: # %bb.0:
+; RV32IXQCILI-NEXT: lui a0, 16
+; RV32IXQCILI-NEXT: ret
+;
; RV64I-LABEL: pos_i32_hi20_only:
; RV64I: # %bb.0:
; RV64I-NEXT: lui a0, 16
@@ -305,6 +337,11 @@ define signext i32 @neg_i32_hi20_only() nounwind {
; RV32I-NEXT: lui a0, 1048560
; RV32I-NEXT: ret
;
+; RV32IXQCILI-LABEL: neg_i32_hi20_only:
+; RV32IXQCILI: # %bb.0:
+; RV32IXQCILI-NEXT: lui a0, 1048560
+; RV32IXQCILI-NEXT: ret
+;
; RV64I-LABEL: neg_i32_hi20_only:
; RV64I: # %bb.0:
; RV64I-NEXT: lui a0, 1048560
@@ -351,6 +388,11 @@ define signext i32 @imm_left_shifted_addi() nounwind {
; RV32I-NEXT: addi a0, a0, -64
; RV32I-NEXT: ret
;
+; RV32IXQCILI-LABEL: imm_left_shifted_addi:
+; RV32IXQCILI: # %bb.0:
+; RV32IXQCILI-NEXT: qc.li a0, 131008
+; RV32IXQCILI-NEXT: ret
+;
; RV64I-LABEL: imm_left_shifted_addi:
; RV64I: # %bb.0:
; RV64I-NEXT: lui a0, 32
@@ -404,6 +446,11 @@ define signext i32 @imm_right_shifted_addi() nounwind {
; RV32I-NEXT: addi a0, a0, -1
; RV32I-NEXT: ret
;
+; RV32IXQCILI-LABEL: imm_right_shifted_addi:
+; RV32IXQCILI: # %bb.0:
+; RV32IXQCILI-NEXT: qc.e.li a0, 2147483647
+; RV32IXQCILI-NEXT: ret
+;
; RV64I-LABEL: imm_right_shifted_addi:
; RV64I: # %bb.0:
; RV64I-NEXT: lui a0, 524288
@@ -457,6 +504,11 @@ define signext i32 @imm_right_shifted_lui() nounwind {
; RV32I-NEXT: addi a0, a0, 580
; RV32I-NEXT: ret
;
+; RV32IXQCILI-LABEL: imm_right_shifted_lui:
+; RV32IXQCILI: # %bb.0:
+; RV32IXQCILI-NEXT: qc.li a0, 229956
+; RV32IXQCILI-NEXT: ret
+;
; RV64I-LABEL: imm_right_shifted_lui:
; RV64I: # %bb.0:
; RV64I-NEXT: lui a0, 56
@@ -508,6 +560,12 @@ define i64 @imm64_1() nounwind {
; RV32I-NEXT: li a1, 0
; RV32I-NEXT: ret
;
+; RV32IXQCILI-LABEL: imm64_1:
+; RV32IXQCILI: # %bb.0:
+; RV32IXQCILI-NEXT: lui a0, 524288
+; RV32IXQCILI-NEXT: li a1, 0
+; RV32IXQCILI-NEXT: ret
+;
; RV64I-LABEL: imm64_1:
; RV64I: # %bb.0:
; RV64I-NEXT: li a0, 1
@@ -558,6 +616,12 @@ define i64 @imm64_2() nounwind {
; RV32I-NEXT: li a1, 0
; RV32I-NEXT: ret
;
+; RV32IXQCILI-LABEL: imm64_2:
+; RV32IXQCILI: # %bb.0:
+; RV32IXQCILI-NEXT: li a0, -1
+; RV32IXQCILI-NEXT: li a1, 0
+; RV32IXQCILI-NEXT: ret
+;
; RV64I-LABEL: imm64_2:
; RV64I: # %bb.0:
; RV64I-NEXT: li a0, -1
@@ -609,6 +673,12 @@ define i64 @imm64_3() nounwind {
; RV32I-NEXT: li a0, 0
; RV32I-NEXT: ret
;
+; RV32IXQCILI-LABEL: imm64_3:
+; RV32IXQCILI: # %bb.0:
+; RV32IXQCILI-NEXT: li a1, 1
+; RV32IXQCILI-NEXT: li a0, 0
+; RV32IXQCILI-NEXT: ret
+;
; RV64I-LABEL: imm64_3:
; RV64I: # %bb.0:
; RV64I-NEXT: li a0, 1
@@ -659,6 +729,12 @@ define i64 @imm64_4() nounwind {
; RV32I-NEXT: li a0, 0
; RV32I-NEXT: ret
;
+; RV32IXQCILI-LABEL: imm64_4:
+; RV32IXQCILI: # %bb.0:
+; RV32IXQCILI-NEXT: lui a1, 524288
+; RV32IXQCILI-NEXT: li a0, 0
+; RV32IXQCILI-NEXT: ret
+;
; RV64I-LABEL: imm64_4:
; RV64I: # %bb.0:
; RV64I-NEXT: li a0, -1
@@ -709,6 +785,12 @@ define i64 @imm64_5() nounwind {
; RV32I-NEXT: li a0, 0
; RV32I-NEXT: ret
;
+; RV32IXQCILI-LABEL: imm64_5:
+; RV32IXQCILI: # %bb.0:
+; RV32IXQCILI-NEXT: lui a1, 524288
+; RV32IXQCILI-NEXT: li a0, 0
+; RV32IXQCILI-NEXT: ret
+;
; RV64I-LABEL: imm64_5:
; RV64I: # %bb.0:
; RV64I-NEXT: li a0, -1
@@ -760,6 +842,12 @@ define i64 @imm64_6() nounwind {
; RV32I-NEXT: li a0, 0
; RV32I-NEXT: ret
;
+; RV32IXQCILI-LABEL: imm64_6:
+; RV32IXQCILI: # %bb.0:
+; RV32IXQCILI-NEXT: qc.e.li a1, 305419896
+; RV32IXQCILI-NEXT: li a0, 0
+; RV32IXQCILI-NEXT: ret
+;
; RV64I-LABEL: imm64_6:
; RV64I: # %bb.0:
; RV64I-NEXT: lui a0, 9321
@@ -819,6 +907,12 @@ define i64 @imm64_7() nounwind {
; RV32I-NEXT: lui a1, 458752
; RV32I-NEXT: ret
;
+; RV32IXQCILI-LABEL: imm64_7:
+; RV32IXQCILI: # %bb.0:
+; RV32IXQCILI-NEXT: qc.e.li a0, 184549391
+; RV32IXQCILI-NEXT: lui a1, 458752
+; RV32IXQCILI-NEXT: ret
+;
; RV64I-LABEL: imm64_7:
; RV64I: # %bb.0:
; RV64I-NEXT: li a0, 7
@@ -893,6 +987,12 @@ define i64 @imm64_8() nounwind {
; RV32I-NEXT: addi a1, a1, 1656
; RV32I-NEXT: ret
;
+; RV32IXQCILI-LABEL: imm64_8:
+; RV32IXQCILI: # %bb.0:
+; RV32IXQCILI-NEXT: qc.e.li a0, -1698898192
+; RV32IXQCILI-NEXT: qc.e.li a1, 305419896
+; RV32IXQCILI-NEXT: ret
+;
; RV64-NOPOOL-LABEL: imm64_8:
; RV64-NOPOOL: # %bb.0:
; RV64-NOPOOL-NEXT: lui a0, 583
@@ -987,6 +1087,12 @@ define i64 @imm64_9() nounwind {
; RV32I-NEXT: li a1, -1
; RV32I-NEXT: ret
;
+; RV32IXQCILI-LABEL: imm64_9:
+; RV32IXQCILI: # %bb.0:
+; RV32IXQCILI-NEXT: li a0, -1
+; RV32IXQCILI-NEXT: li a1, -1
+; RV32IXQCILI-NEXT: ret
+;
; RV64I-LABEL: imm64_9:
; RV64I: # %bb.0:
; RV64I-NEXT: li a0, -1
@@ -1035,6 +1141,12 @@ define i64 @imm_left_shifted_lui_1() nounwind {
; RV32I-NEXT: li a1, 0
; RV32I-NEXT: ret
;
+; RV32IXQCILI-LABEL: imm_left_shifted_lui_1:
+; RV32IXQCILI: # %bb.0:
+; RV32IXQCILI-NEXT: lui a0, 524290
+; RV32IXQCILI-NEXT: li a1, 0
+; RV32IXQCILI-NEXT: ret
+;
; RV64I-LABEL: imm_left_shifted_lui_1:
; RV64I: # %bb.0:
; RV64I-NEXT: lui a0, 262145
@@ -1086,6 +1198,12 @@ define i64 @imm_left_shifted_lui_2() nounwind {
; RV32I-NEXT: li a1, 1
; RV32I-NEXT: ret
;
+; RV32IXQCILI-LABEL: imm_left_shifted_lui_2:
+; RV32IXQCILI: # %bb.0:
+; RV32IXQCILI-NEXT: lui a0, 4
+; RV32IXQCILI-NEXT: li a1, 1
+; RV32IXQCILI-NEXT: ret
+;
; RV64I-LABEL: imm_left_shifted_lui_2:
; RV64I: # %bb.0:
; RV64I-NEXT: lui a0, 262145
@@ -1138,6 +1256,12 @@ define i64 @imm_left_shifted_lui_3() nounwind {
; RV32I-NEXT: li a0, 0
; RV32I-NEXT: ret
;
+; RV32IXQCILI-LABEL: imm_left_shifted_lui_3:
+; RV32IXQCILI: # %bb.0:
+; RV32IXQCILI-NEXT: qc.li a1, 4097
+; RV32IXQCILI-NEXT: li a0, 0
+; RV32IXQCILI-NEXT: ret
+;
; RV64I-LABEL: imm_left_shifted_lui_3:
; RV64I: # %bb.0:
; RV64I-NEXT: lui a0, 4097
@@ -1195,6 +1319,12 @@ define i64 @imm_right_shifted_lui_1() nounwind {
; RV32I-NEXT: addi a1, a1, -1
; RV32I-NEXT: ret
;
+; RV32IXQCILI-LABEL: imm_right_shifted_lui_1:
+; RV32IXQCILI: # %bb.0:
+; RV32IXQCILI-NEXT: qc.li a0, -4095
+; RV32IXQCILI-NEXT: qc.li a1, 65535
+; RV32IXQCILI-NEXT: ret
+;
; RV64I-LABEL: imm_right_shifted_lui_1:
; RV64I: # %bb.0:
; RV64I-NEXT: lui a0, 983056
@@ -1249,6 +1379,12 @@ define i64 @imm_right_shifted_lui_2() nounwind {
; RV32I-NEXT: li a1, 255
; RV32I-NEXT: ret
;
+; RV32IXQCILI-LABEL: imm_right_shifted_lui_2:
+; RV32IXQCILI: # %bb.0:
+; RV32IXQCILI-NEXT: qc.li a0, -4095
+; RV32IXQCILI-NEXT: li a1, 255
+; RV32IXQCILI-NEXT: ret
+;
; RV64I-LABEL: imm_right_shifted_lui_2:
; RV64I: # %bb.0:
; RV64I-NEXT: lui a0, 1044481
@@ -1310,6 +1446,12 @@ define i64 @imm_decoupled_lui_addi() nounwind {
; RV32I-NEXT: lui a1, 1
; RV32I-NEXT: ret
;
+; RV32IXQCILI-LABEL: imm_decoupled_lui_addi:
+; RV32IXQCILI: # %bb.0:
+; RV32IXQCILI-NEXT: li a0, -3
+; RV32IXQCILI-NEXT: lui a1, 1
+; RV32IXQCILI-NEXT: ret
+;
; RV64I-LABEL: imm_decoupled_lui_addi:
; RV64I: # %bb.0:
; RV64I-NEXT: lui a0, 4097
@@ -1370,6 +1512,12 @@ define i64 @imm_end_xori_1() nounwind {
; RV32I-NEXT: lui a1, 917504
; RV32I-NEXT: ret
;
+; RV32IXQCILI-LABEL: imm_end_xori_1:
+; RV32IXQCILI: # %bb.0:
+; RV32IXQCILI-NEXT: qc.e.li a0, 33554431
+; RV32IXQCILI-NEXT: lui a1, 917504
+; RV32IXQCILI-NEXT: ret
+;
; RV64I-LABEL: imm_end_xori_1:
; RV64I: # %bb.0:
; RV64I-NEXT: lui a0, 983040
@@ -1432,6 +1580,12 @@ define i64 @imm_end_2addi_1() nounwind {
; RV32I-NEXT: addi a1, a1, 127
; RV32I-NEXT: ret
;
+; RV32IXQCILI-LABEL: imm_end_2addi_1:
+; RV32IXQCILI: # %bb.0:
+; RV32IXQCILI-NEXT: qc.li a0, -2049
+; RV32IXQCILI-NEXT: qc.li a1, -262017
+; RV32IXQCILI-NEXT: ret
+;
; RV64I-LABEL: imm_end_2addi_1:
; RV64I: # %bb.0:
; RV64I-NEXT: li a0, -2047
@@ -1501,6 +1655,12 @@ define i64 @imm_2reg_1() nounwind {
; RV32I-NEXT: lui a1, 983040
; RV32I-NEXT: ret
;
+; RV32IXQCILI-LABEL: imm_2reg_1:
+; RV32IXQCILI: # %bb.0:
+; RV32IXQCILI-NEXT: qc.e.li a0, 305419896
+; RV32IXQCILI-NEXT: lui a1, 983040
+; RV32IXQCILI-NEXT: ret
+;
; RV64I-LABEL: imm_2reg_1:
; RV64I: # %bb.0:
; RV64I-NEXT: lui a0, 74565
@@ -1565,6 +1725,12 @@ define void @imm_store_i8_neg1(ptr %p) nounwind {
; RV32I-NEXT: sb a1, 0(a0)
; RV32I-NEXT: ret
;
+; RV32IXQCILI-LABEL: imm_store_i8_neg1:
+; RV32IXQCILI: # %bb.0:
+; RV32IXQCILI-NEXT: li a1, -1
+; RV32IXQCILI-NEXT: sb a1, 0(a0)
+; RV32IXQCILI-NEXT: ret
+;
; RV64I-LABEL: imm_store_i8_neg1:
; RV64I: # %bb.0:
; RV64I-NEXT: li a1, -1
@@ -1617,6 +1783,12 @@ define void @imm_store_i16_neg1(ptr %p) nounwind {
; RV32I-NEXT: sh a1, 0(a0)
; RV32I-NEXT: ret
;
+; RV32IXQCILI-LABEL: imm_store_i16_neg1:
+; RV32IXQCILI: # %bb.0:
+; RV32IXQCILI-NEXT: li a1, -1
+; RV32IXQCILI-NEXT: sh a1, 0(a0)
+; RV32IXQCILI-NEXT: ret
+;
; RV64I-LABEL: imm_store_i16_neg1:
; RV64I: # %bb.0:
; RV64I-NEXT: li a1, -1
@@ -1669,6 +1841,12 @@ define void @imm_store_i32_neg1(ptr %p) nounwind {
; RV32I-NEXT: sw a1, 0(a0)
; RV32I-NEXT: ret
;
+; RV32IXQCILI-LABEL: imm_store_i32_neg1:
+; RV32IXQCILI: # %bb.0:
+; RV32IXQCILI-NEXT: li a1, -1
+; RV32IXQCILI-NEXT: sw a1, 0(a0)
+; RV32IXQCILI-NEXT: ret
+;
; RV64I-LABEL: imm_store_i32_neg1:
; RV64I: # %bb.0:
; RV64I-NEXT: li a1, -1
@@ -1722,6 +1900,12 @@ define i64 @imm_5372288229() {
; RV32I-NEXT: li a1, 1
; RV32I-NEXT: ret
;
+; RV32IXQCILI-LABEL: imm_5372288229:
+; RV32IXQCILI: # %bb.0:
+; RV32IXQCILI-NEXT: qc.e.li a0, 1077320933
+; RV32IXQCILI-NEXT: li a1, 1
+; RV32IXQCILI-NEXT: ret
+;
; RV64I-LABEL: imm_5372288229:
; RV64I: # %bb.0:
; RV64I-NEXT: lui a0, 160
@@ -1785,6 +1969,12 @@ define i64 @imm_neg_5372288229() {
; RV32I-NEXT: li a1, -2
; RV32I-NEXT: ret
;
+; RV32IXQCILI-LABEL: imm_neg_5372288229:
+; RV32IXQCILI: # %bb.0:
+; RV32IXQCILI-NEXT: qc.e.li a0, -1077320933
+; RV32IXQCILI-NEXT: li a1, -2
+; RV32IXQCILI-NEXT: ret
+;
; RV64I-LABEL: imm_neg_5372288229:
; RV64I: # %bb.0:
; RV64I-NEXT: lui a0, 1048416
@@ -1848,6 +2038,12 @@ define i64 @imm_8953813715() {
; RV32I-NEXT: li a1, 2
; RV32I-NEXT: ret
;
+; RV32IXQCILI-LABEL: imm_8953813715:
+; RV32IXQCILI: # %bb.0:
+; RV32IXQCILI-NEXT: qc.e.li a0, 363879123
+; RV32IXQCILI-NEXT: li a1, 2
+; RV32IXQCILI-NEXT: ret
+;
; RV64I-LABEL: imm_8953813715:
; RV64I: # %bb.0:
; RV64I-NEXT: lui a0, 267
@@ -1911,6 +2107,12 @@ define i64 @imm_neg_8953813715() {
; RV32I-NEXT: li a1, -3
; RV32I-NEXT: ret
;
+; RV32IXQCILI-LABEL: imm_neg_8953813715:
+; RV32IXQCILI: # %bb.0:
+; RV32IXQCILI-NEXT: qc.e.li a0, -363879123
+; RV32IXQCILI-NEXT: li a1, -3
+; RV32IXQCILI-NEXT: ret
+;
; RV64I-LABEL: imm_neg_8953813715:
; RV64I: # %bb.0:
; RV64I-NEXT: lui a0, 1048309
@@ -1974,6 +2176,12 @@ define i64 @imm_16116864687() {
; RV32I-NEXT: li a1, 3
; RV32I-NEXT: ret
;
+; RV32IXQCILI-LABEL: imm_16116864687:
+; RV32IXQCILI: # %bb.0:
+; RV32IXQCILI-NEXT: qc.e.li a0, -1063004497
+; RV32IXQCILI-NEXT: li a1, 3
+; RV32IXQCILI-NEXT: ret
+;
; RV64I-LABEL: imm_16116864687:
; RV64I: # %bb.0:
; RV64I-NEXT: lui a0, 961
@@ -2038,6 +2246,12 @@ define i64 @imm_neg_16116864687() {
; RV32I-NEXT: li a1, -4
; RV32I-NEXT: ret
;
+; RV32IXQCILI-LABEL: imm_neg_16116864687:
+; RV32IXQCILI: # %bb.0:
+; RV32IXQCILI-NEXT: qc.e.li a0, 1063004497
+; RV32IXQCILI-NEXT: li a1, -4
+; RV32IXQCILI-NEXT: ret
+;
; RV64I-LABEL: imm_neg_16116864687:
; RV64I: # %bb.0:
; RV64I-NEXT: lui a0, 1047615
@@ -2102,6 +2316,12 @@ define i64 @imm_2344336315() {
; RV32I-NEXT: li a1, 0
; RV32I-NEXT: ret
;
+; RV32IXQCILI-LABEL: imm_2344336315:
+; RV32IXQCILI: # %bb.0:
+; RV32IXQCILI-NEXT: qc.e.li a0, -1950630981
+; RV32IXQCILI-NEXT: li a1, 0
+; RV32IXQCILI-NEXT: ret
+;
; RV64I-LABEL: imm_2344336315:
; RV64I: # %bb.0:
; RV64I-NEXT: lui a0, 143087
@@ -2161,6 +2381,12 @@ define i64 @imm_70370820078523() {
; RV32I-NEXT: lui a1, 4
; RV32I-NEXT: ret
;
+; RV32IXQCILI-LABEL: imm_70370820078523:
+; RV32IXQCILI: # %bb.0:
+; RV32IXQCILI-NEXT: qc.e.li a0, 2075900859
+; RV32IXQCILI-NEXT: lui a1, 4
+; RV32IXQCILI-NEXT: ret
+;
; RV64-NOPOOL-LABEL: imm_70370820078523:
; RV64-NOPOOL: # %bb.0:
; RV64-NOPOOL-NEXT: lui a0, 256
@@ -2241,6 +2467,12 @@ define i64 @imm_neg_9223372034778874949() {
; RV32I-NEXT: lui a1, 524288
; RV32I-NEXT: ret
;
+; RV32IXQCILI-LABEL: imm_neg_9223372034778874949:
+; RV32IXQCILI: # %bb.0:
+; RV32IXQCILI-NEXT: qc.e.li a0, 2075900859
+; RV32IXQCILI-NEXT: lui a1, 524288
+; RV32IXQCILI-NEXT: ret
+;
; RV64I-LABEL: imm_neg_9223372034778874949:
; RV64I: # %bb.0:
; RV64I-NEXT: lui a0, 506812
@@ -2305,6 +2537,12 @@ define i64 @imm_neg_9223301666034697285() {
; RV32I-NEXT: lui a1, 524292
; RV32I-NEXT: ret
;
+; RV32IXQCILI-LABEL: imm_neg_9223301666034697285:
+; RV32IXQCILI: # %bb.0:
+; RV32IXQCILI-NEXT: qc.e.li a0, 2075900859
+; RV32IXQCILI-NEXT: lui a1, 524292
+; RV32IXQCILI-NEXT: ret
+;
; RV64-NOPOOL-LABEL: imm_neg_9223301666034697285:
; RV64-NOPOOL: # %bb.0:
; RV64-NOPOOL-NEXT: lui a0, 917505
@@ -2391,6 +2629,12 @@ define i64 @imm_neg_2219066437() {
; RV32I-NEXT: li a1, -1
; RV32I-NEXT: ret
;
+; RV32IXQCILI-LABEL: imm_neg_2219066437:
+; RV32IXQCILI: # %bb.0:
+; RV32IXQCILI-NEXT: qc.e.li a0, 2075900859
+; RV32IXQCILI-NEXT: li a1, -1
+; RV32IXQCILI-NEXT: ret
+;
; RV64I-LABEL: imm_neg_2219066437:
; RV64I: # %bb.0:
; RV64I-NEXT: lui a0, 913135
@@ -2451,6 +2695,12 @@ define i64 @imm_neg_8798043653189() {
; RV32I-NEXT: addi a1, a1, 2047
; RV32I-NEXT: ret
;
+; RV32IXQCILI-LABEL: imm_neg_8798043653189:
+; RV32IXQCILI: # %bb.0:
+; RV32IXQCILI-NEXT: qc.e.li a0, -1950630981
+; RV32IXQCILI-NEXT: qc.li a1, -2049
+; RV32IXQCILI-NEXT: ret
+;
; RV64I-LABEL: imm_neg_8798043653189:
; RV64I: # %bb.0:
; RV64I-NEXT: lui a0, 917475
@@ -2517,6 +2767,12 @@ define i64 @imm_9223372034904144827() {
; RV32I-NEXT: addi a1, a1, -1
; RV32I-NEXT: ret
;
+; RV32IXQCILI-LABEL: imm_9223372034904144827:
+; RV32IXQCILI: # %bb.0:
+; RV32IXQCILI-NEXT: qc.e.li a0, -1950630981
+; RV32IXQCILI-NEXT: qc.e.li a1, 2147483647
+; RV32IXQCILI-NEXT: ret
+;
; RV64I-LABEL: imm_9223372034904144827:
; RV64I: # %bb.0:
; RV64I-NEXT: lui a0, 572348
@@ -2583,6 +2839,12 @@ define i64 @imm_neg_9223354442718100411() {
; RV32I-NEXT: addi a1, a1, -1
; RV32I-NEXT: ret
;
+; RV32IXQCILI-LABEL: imm_neg_9223354442718100411:
+; RV32IXQCILI: # %bb.0:
+; RV32IXQCILI-NEXT: qc.e.li a0, -1950630981
+; RV32IXQCILI-NEXT: qc.e.li a1, 2147479551
+; RV32IXQCILI-NEXT: ret
+;
; RV64-NOPOOL-LABEL: imm_neg_9223354442718100411:
; RV64-NOPOOL: # %bb.0:
; RV64-NOPOOL-NEXT: lui a0, 524287
@@ -2670,6 +2932,12 @@ define i64 @imm_2863311530() {
; RV32I-NEXT: li a1, 0
; RV32I-NEXT: ret
;
+; RV32IXQCILI-LABEL: imm_2863311530:
+; RV32IXQCILI: # %bb.0:
+; RV32IXQCILI-NEXT: qc.e.li a0, -1431655766
+; RV32IXQCILI-NEXT: li a1, 0
+; RV32IXQCILI-NEXT: ret
+;
; RV64I-LABEL: imm_2863311530:
; RV64I: # %bb.0:
; RV64I-NEXT: lui a0, 349525
@@ -2729,6 +2997,12 @@ define i64 @imm_neg_2863311530() {
; RV32I-NEXT: li a1, -1
; RV32I-NEXT: ret
;
+; RV32IXQCILI-LABEL: imm_neg_2863311530:
+; RV32IXQCILI: # %bb.0:
+; RV32IXQCILI-NEXT: qc.e.li a0, 1431655766
+; RV32IXQCILI-NEXT: li a1, -1
+; RV32IXQCILI-NEXT: ret
+;
; RV64I-LABEL: imm_neg_2863311530:
; RV64I: # %bb.0:
; RV64I-NEXT: lui a0, 699051
@@ -2788,6 +3062,12 @@ define i64 @imm_2147486378() {
; RV32I-NEXT: li a1, 0
; RV32I-NEXT: ret
;
+; RV32IXQCILI-LABEL: imm_2147486378:
+; RV32IXQCILI: # %bb.0:
+; RV32IXQCILI-NEXT: qc.e.li a0, -2147482283
+; RV32IXQCILI-NEXT: li a1, 0
+; RV32IXQCILI-NEXT: ret
+;
; RV64I-LABEL: imm_2147486378:
; RV64I: # %bb.0:
; RV64I-NEXT: li a0, 1
@@ -2846,6 +3126,12 @@ define i64 @imm_neg_2147485013() {
; RV32I-NEXT: li a1, -1
; RV32I-NEXT: ret
;
+; RV32IXQCILI-LABEL: imm_neg_2147485013:
+; RV32IXQCILI: # %bb.0:
+; RV32IXQCILI-NEXT: qc.e.li a0, 2147482283
+; RV32IXQCILI-NEXT: li a1, -1
+; RV32IXQCILI-NEXT: ret
+;
; RV64I-LABEL: imm_neg_2147485013:
; RV64I: # %bb.0:
; RV64I-NEXT: lui a0, 524288
@@ -2900,6 +3186,12 @@ define i64 @imm_12900924131259() {
; RV32I-NEXT: addi a1, a1, -1093
; RV32I-NEXT: ret
;
+; RV32IXQCILI-LABEL: imm_12900924131259:
+; RV32IXQCILI: # %bb.0:
+; RV32IXQCILI-NEXT: qc.e.li a0, -1157625925
+; RV32IXQCILI-NEXT: qc.li a1, 3003
+; RV32IXQCILI-NEXT: ret
+;
; RV64I-LABEL: imm_12900924131259:
; RV64I: # %bb.0:
; RV64I-NEXT: lui a0, 188
@@ -2964,6 +3256,12 @@ define i64 @imm_50394234880() {
; RV32I-NEXT: li a1, 11
; RV32I-NEXT: ret
;
+; RV32IXQCILI-LABEL: imm_50394234880:
+; RV32IXQCILI: # %bb.0:
+; RV32IXQCILI-NEXT: lui a0, 768944
+; RV32IXQCILI-NEXT: li a1, 11
+; RV32IXQCILI-NEXT: ret
+;
; RV64I-LABEL: imm_50394234880:
; RV64I: # %bb.0:
; RV64I-NEXT: lui a0, 188
@@ -3022,6 +3320,12 @@ define i64 @imm_12900936431479() {
; RV32I-NEXT: addi a1, a1, -1093
; RV32I-NEXT: ret
;
+; RV32IXQCILI-LABEL: imm_12900936431479:
+; RV32IXQCILI: # %bb.0:
+; RV32IXQCILI-NEXT: qc.e.li a0, -1145325705
+; RV32IXQCILI-NEXT: qc.li a1, 3003
+; RV32IXQCILI-NEXT: ret
+;
; RV64I-LABEL: imm_12900936431479:
; RV64I: # %bb.0:
; RV64I-NEXT: lui a0, 192239
@@ -3094,6 +3398,12 @@ define i64 @imm_12900918536874() {
; RV32I-NEXT: addi a1, a1, -1093
; RV32I-NEXT: ret
;
+; RV32IXQCILI-LABEL: imm_12900918536874:
+; RV32IXQCILI: # %bb.0:
+; RV32IXQCILI-NEXT: qc.e.li a0, -1163220310
+; RV32IXQCILI-NEXT: qc.li a1, 3003
+; RV32IXQCILI-NEXT: ret
+;
; RV64I-LABEL: imm_12900918536874:
; RV64I: # %bb.0:
; RV64I-NEXT: lui a0, 384477
@@ -3166,6 +3476,12 @@ define i64 @imm_12900925247761() {
; RV32I-NEXT: addi a1, a1, -1093
; RV32I-NEXT: ret
;
+; RV32IXQCILI-LABEL: imm_12900925247761:
+; RV32IXQCILI: # %bb.0:
+; RV32IXQCILI-NEXT: qc.e.li a0, -1156509423
+; RV32IXQCILI-NEXT: qc.li a1, 3003
+; RV32IXQCILI-NEXT: ret
+;
; RV64I-LABEL: imm_12900925247761:
; RV64I: # %bb.0:
; RV64I-NEXT: lui a0, 384478
@@ -3237,6 +3553,12 @@ define i64 @imm_7158272001() {
; RV32I-NEXT: li a1, 1
; RV32I-NEXT: ret
;
+; RV32IXQCILI-LABEL: imm_7158272001:
+; RV32IXQCILI: # %bb.0:
+; RV32IXQCILI-NEXT: qc.e.li a0, -1431662591
+; RV32IXQCILI-NEXT: li a1, 1
+; RV32IXQCILI-NEXT: ret
+;
; RV64I-LABEL: imm_7158272001:
; RV64I: # %bb.0:
; RV64I-NEXT: lui a0, 427
@@ -3301,6 +3623,12 @@ define i64 @imm_12884889601() {
; RV32I-NEXT: li a1, 2
; RV32I-NEXT: ret
;
+; RV32IXQCILI-LABEL: imm_12884889601:
+; RV32IXQCILI: # %bb.0:
+; RV32IXQCILI-NEXT: qc.li a0, -12287
+; RV32IXQCILI-NEXT: li a1, 2
+; RV32IXQCILI-NEXT: ret
+;
; RV64I-LABEL: imm_12884889601:
; RV64I: # %bb.0:
; RV64I-NEXT: lui a0, 768
@@ -3365,6 +3693,12 @@ define i64 @imm_neg_3435982847() {
; RV32I-NEXT: li a1, -1
; RV32I-NEXT: ret
;
+; RV32IXQCILI-LABEL: imm_neg_3435982847:
+; RV32IXQCILI: # %bb.0:
+; RV32IXQCILI-NEXT: qc.e.li a0, 858984449
+; RV32IXQCILI-NEXT: li a1, -1
+; RV32IXQCILI-NEXT: ret
+;
; RV64I-LABEL: imm_neg_3435982847:
; RV64I: # %bb.0:
; RV64I-NEXT: lui a0, 1048371
@@ -3428,6 +3762,12 @@ define i64 @imm_neg_5726842879() {
; RV32I-NEXT: li a1, -2
; RV32I-NEXT: ret
;
+; RV32IXQCILI-LABEL: imm_neg_5726842879:
+; RV32IXQCILI: # %bb.0:
+; RV32IXQCILI-NEXT: qc.e.li a0, -1431875583
+; RV32IXQCILI-NEXT: li a1, -2
+; RV32IXQCILI-NEXT: ret
+;
; RV64I-LABEL: imm_neg_5726842879:
; RV64I: # %bb.0:
; RV64I-NEXT: lui a0, 1048235
@@ -3491,6 +3831,12 @@ define i64 @imm_neg_10307948543() {
; RV32I-NEXT: li a1, -3
; RV32I-NEXT: ret
;
+; RV32IXQCILI-LABEL: imm_neg_10307948543:
+; RV32IXQCILI: # %bb.0:
+; RV32IXQCILI-NEXT: qc.e.li a0, -1718013951
+; RV32IXQCILI-NEXT: li a1, -3
+; RV32IXQCILI-NEXT: ret
+;
; RV64I-LABEL: imm_neg_10307948543:
; RV64I: # %bb.0:
; RV64I-NEXT: lui a0, 1047962
@@ -3554,6 +3900,12 @@ define i64 @li_rori_1() {
; RV32I-NEXT: li a0, -1
; RV32I-NEXT: ret
;
+; RV32IXQCILI-LABEL: li_rori_1:
+; RV32IXQCILI: # %bb.0:
+; RV32IXQCILI-NEXT: qc.li a1, -34817
+; RV32IXQCILI-NEXT: li a0, -1
+; RV32IXQCILI-NEXT: ret
+;
; RV64I-LABEL: li_rori_1:
; RV64I: # %bb.0:
; RV64I-NEXT: li a0, -17
@@ -3611,6 +3963,12 @@ define i64 @li_rori_2() {
; RV32I-NEXT: li a0, -6
; RV32I-NEXT: ret
;
+; RV32IXQCILI-LABEL: li_rori_2:
+; RV32IXQCILI: # %bb.0:
+; RV32IXQCILI-NEXT: qc.e.li a1, -1342177281
+; RV32IXQCILI-NEXT: li a0, -6
+; RV32IXQCILI-NEXT: ret
+;
; RV64I-LABEL: li_rori_2:
; RV64I: # %bb.0:
; RV64I-NEXT: li a0, -5
@@ -3668,6 +4026,12 @@ define i64 @li_rori_3() {
; RV32I-NEXT: li a1, -1
; RV32I-NEXT: ret
;
+; RV32IXQCILI-LABEL: li_rori_3:
+; RV32IXQCILI: # %bb.0:
+; RV32IXQCILI-NEXT: qc.e.li a0, 2013265919
+; RV32IXQCILI-NEXT: li a1, -1
+; RV32IXQCILI-NEXT: ret
+;
; RV64I-LABEL: li_rori_3:
; RV64I: # %bb.0:
; RV64I-NEXT: li a0, -17
@@ -3725,6 +4089,12 @@ define i64 @PR54812() {
; RV32I-NEXT: li a1, -1
; RV32I-NEXT: ret
;
+; RV32IXQCILI-LABEL: PR54812:
+; RV32IXQCILI: # %bb.0:
+; RV32IXQCILI-NEXT: lui a0, 521599
+; RV32IXQCILI-NEXT: li a1, -1
+; RV32IXQCILI-NEXT: ret
+;
; RV64I-LABEL: PR54812:
; RV64I: # %bb.0:
; RV64I-NEXT: lui a0, 1048447
@@ -3780,6 +4150,11 @@ define signext i32 @pos_2048() nounwind {
; RV32I-NEXT: slli a0, a0, 11
; RV32I-NEXT: ret
;
+; RV32IXQCILI-LABEL: pos_2048:
+; RV32IXQCILI: # %bb.0:
+; RV32IXQCILI-NEXT: qc.li a0, 2048
+; RV32IXQCILI-NEXT: ret
+;
; RV64I-LABEL: pos_2048:
; RV64I: # %bb.0:
; RV64I-NEXT: li a0, 1
@@ -3831,6 +4206,12 @@ define i64 @imm64_same_lo_hi() nounwind {
; RV32I-NEXT: mv a1, a0
; RV32I-NEXT: ret
;
+; RV32IXQCILI-LABEL: imm64_same_lo_hi:
+; RV32IXQCILI: # %bb.0:
+; RV32IXQCILI-NEXT: qc.e.li a0, 269488144
+; RV32IXQCILI-NEXT: mv a1, a0
+; RV32IXQCILI-NEXT: ret
+;
; RV64I-LABEL: imm64_same_lo_hi:
; RV64I: # %bb.0:
; RV64I-NEXT: lui a0, 65793
@@ -3897,6 +4278,12 @@ define i64 @imm64_same_lo_hi_optsize() nounwind optsize {
; RV32I-NEXT: mv a1, a0
; RV32I-NEXT: ret
;
+; RV32IXQCILI-LABEL: imm64_same_lo_hi_optsize:
+; RV32IXQCILI: # %bb.0:
+; RV32IXQCILI-NEXT: qc.e.li a0, 269488144
+; RV32IXQCILI-NEXT: mv a1, a0
+; RV32IXQCILI-NEXT: ret
+;
; RV64-NOPOOL-LABEL: imm64_same_lo_hi_optsize:
; RV64-NOPOOL: # %bb.0:
; RV64-NOPOOL-NEXT: lui a0, 65793
@@ -3969,6 +4356,12 @@ define i64 @imm64_same_lo_hi_negative() nounwind {
; RV32I-NEXT: mv a1, a0
; RV32I-NEXT: ret
;
+; RV32IXQCILI-LABEL: imm64_same_lo_hi_negative:
+; RV32IXQCILI: # %bb.0:
+; RV32IXQCILI-NEXT: qc.e.li a0, -2139062144
+; RV32IXQCILI-NEXT: mv a1, a0
+; RV32IXQCILI-NEXT: ret
+;
; RV64-NOPOOL-LABEL: imm64_same_lo_hi_negative:
; RV64-NOPOOL: # %bb.0:
; RV64-NOPOOL-NEXT: lui a0, 983297
@@ -4054,6 +4447,12 @@ define i64 @imm64_0x8000080000000() {
; RV32I-NEXT: lui a1, 128
; RV32I-NEXT: ret
;
+; RV32IXQCILI-LABEL: imm64_0x8000080000000:
+; RV32IXQCILI: # %bb.0:
+; RV32IXQCILI-NEXT: lui a0, 524288
+; RV32IXQCILI-NEXT: lui a1, 128
+; RV32IXQCILI-NEXT: ret
+;
; RV64I-LABEL: imm64_0x8000080000000:
; RV64I: # %bb.0:
; RV64I-NEXT: lui a0, 256
@@ -4111,6 +4510,12 @@ define i64 @imm64_0x10000100000000() {
; RV32I-NEXT: li a0, 0
; RV32I-NEXT: ret
;
+; RV32IXQCILI-LABEL: imm64_0x10000100000000:
+; RV32IXQCILI: # %bb.0:
+; RV32IXQCILI-NEXT: qc.e.li a1, 1048577
+; RV32IXQCILI-NEXT: li a0, 0
+; RV32IXQCILI-NEXT: ret
+;
; RV64I-LABEL: imm64_0x10000100000000:
; RV64I: # %bb.0:
; RV64I-NEXT: lui a0, 256
@@ -4170,6 +4575,12 @@ define i64 @imm64_0xFF7FFFFF7FFFFFFE() {
; RV32I-NEXT: addi a1, a1, -1
; RV32I-NEXT: ret
;
+; RV32IXQCILI-LABEL: imm64_0xFF7FFFFF7FFFFFFE:
+; RV32IXQCILI: # %bb.0:
+; RV32IXQCILI-NEXT: qc.e.li a0, 2147483647
+; RV32IXQCILI-NEXT: qc.e.li a1, -8388609
+; RV32IXQCILI-NEXT: ret
+;
; RV64I-LABEL: imm64_0xFF7FFFFF7FFFFFFE:
; RV64I: # %bb.0:
; RV64I-NEXT: lui a0, 1044480
diff --git a/llvm/test/MC/RISCV/xqcili-li.s b/llvm/test/MC/RISCV/xqcili-li.s
new file mode 100644
index 0000000000000..47eefffe88026
--- /dev/null
+++ b/llvm/test/MC/RISCV/xqcili-li.s
@@ -0,0 +1,39 @@
+# Xqcili - Check aliases for li instruction
+# RUN: llvm-mc %s -triple=riscv32 -mattr=+experimental-xqcili -riscv-no-aliases \
+# RUN: | FileCheck -check-prefixes=CHECK-INST %s
+# RUN: llvm-mc %s -triple=riscv32 -riscv-no-aliases \
+# RUN: | FileCheck -check-prefixes=CHECK-INST-RISCV32 %s
+
+# CHECK-INST: qc.li a0, 2048
+# CHECK-INST-RISCV32: addi a0, zero, 1
+# CHECK-INST-RISCV32: slli a0, a0, 11
+li x10, 2048
+
+# CHECK-INST: addi a0, zero, 2047
+# CHECK-INST-RISCV32: addi a0, zero, 2047
+li x10, 2047
+
+# CHECK-INST: addi a0, zero, -2048
+# CHECK-INST-RISCV32: addi a0, zero, -2048
+li x10, -2048
+
+# CHECK-INST: addi a0, zero, -2047
+# CHECK-INST-RISCV32: addi a0, zero, -2047
+li x10, -2047
+
+# CHECK-INST: lui a0, 512
+# CHECK-INST-RISCV32: lui a0, 512
+li x10, 2097152
+
+# CHECK-INST: lui a0, 1
+# CHECK-INST-RISCV32: lui a0, 1
+li x10, 4096
+
+# CHECK-INST: qc.e.li a0, 1048577
+# CHECK-INST-RISCV32: lui a0, 256
+# CHECK-INST-RISCV32: addi a0, a0, 1
+li x10, 1048577
+
+# CHECK-INST: lui a0, 512
+# CHECK-INST-RISCV32: lui a0, 512
+li x10, 2097152
>From 4bbe4d6244c2a3310042689bede97528a2d43bca Mon Sep 17 00:00:00 2001
From: Sam Elliott <quic_aelliott at quicinc.com>
Date: Mon, 24 Mar 2025 10:23:10 -0700
Subject: [PATCH 2/3] Release Notes
---
llvm/docs/ReleaseNotes.md | 2 ++
1 file changed, 2 insertions(+)
diff --git a/llvm/docs/ReleaseNotes.md b/llvm/docs/ReleaseNotes.md
index 3b11cc3b09683..f3e90cce08d7f 100644
--- a/llvm/docs/ReleaseNotes.md
+++ b/llvm/docs/ReleaseNotes.md
@@ -141,6 +141,8 @@ Changes to the RISC-V Backend
* Adds assembler support for the 'Zclsd` (Compressed Load/Store Pair Instructions)
extension.
* Adds experimental assembler support for Zvqdotq.
+* When the experimental extension `Xqcili` is enabled, `qc.e.li` and `qc.li` may
+ now be used to materialize immediates.
Changes to the WebAssembly Backend
----------------------------------
>From 21c66fb8d7f586a94acc46a72a38a625b2b5ee56 Mon Sep 17 00:00:00 2001
From: Sam Elliott <quic_aelliott at quicinc.com>
Date: Mon, 24 Mar 2025 12:57:30 -0700
Subject: [PATCH 3/3] fixup! [RISCV][Xqcili] Implement Load Immediate Support
---
llvm/lib/Target/RISCV/MCTargetDesc/RISCVMatInt.cpp | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/llvm/lib/Target/RISCV/MCTargetDesc/RISCVMatInt.cpp b/llvm/lib/Target/RISCV/MCTargetDesc/RISCVMatInt.cpp
index 81f25054bf878..8ea2548258fdb 100644
--- a/llvm/lib/Target/RISCV/MCTargetDesc/RISCVMatInt.cpp
+++ b/llvm/lib/Target/RISCV/MCTargetDesc/RISCVMatInt.cpp
@@ -62,8 +62,7 @@ static void generateInstSeqImpl(int64_t Val, const MCSubtargetInfo &STI,
}
if (!IsRV64 && STI.hasFeature(RISCV::FeatureVendorXqcili)) {
- bool FitsOneStandardInst =
- ((Val & 0xFFF) == 0) || (((Val + 0x800) & 0xFFFFF000) == 0);
+ bool FitsOneStandardInst = ((Val & 0xFFF) == 0) || isInt<12>(Val);
// 20-bit signed immediates that don't fit into `ADDI` or `LUI` should use
// `QC.LI` (a single 32-bit instruction).
More information about the llvm-commits
mailing list