[llvm] 994d882 - [RISCV] Add an slli.uw pattern using zext for -riscv-experimental-rv64-legal-i32
Craig Topper via llvm-commits
llvm-commits at lists.llvm.org
Sat Nov 11 14:46:26 PST 2023
Author: Craig Topper
Date: 2023-11-11T14:41:56-08:00
New Revision: 994d882e151c07498ee47bff09f58724113ed87c
URL: https://github.com/llvm/llvm-project/commit/994d882e151c07498ee47bff09f58724113ed87c
DIFF: https://github.com/llvm/llvm-project/commit/994d882e151c07498ee47bff09f58724113ed87c.diff
LOG: [RISCV] Add an slli.uw pattern using zext for -riscv-experimental-rv64-legal-i32
We already had the pattern for GlobalISel. Move it over to SelectionDAG.
Added:
Modified:
llvm/lib/Target/RISCV/RISCVGISel.td
llvm/lib/Target/RISCV/RISCVInstrInfoZb.td
llvm/test/CodeGen/RISCV/rv64-legal-i32/rv64zba.ll
Removed:
################################################################################
diff --git a/llvm/lib/Target/RISCV/RISCVGISel.td b/llvm/lib/Target/RISCV/RISCVGISel.td
index abe190ee8edc53a..b675446380e4228 100644
--- a/llvm/lib/Target/RISCV/RISCVGISel.td
+++ b/llvm/lib/Target/RISCV/RISCVGISel.td
@@ -87,13 +87,6 @@ def : Pat<(i32 (sra GPR:$rs1, (i32 GPR:$rs2))), (SRAW GPR:$rs1, GPR:$rs2)>;
def : Pat<(i32 (srl GPR:$rs1, (i32 GPR:$rs2))), (SRLW GPR:$rs1, GPR:$rs2)>;
}
-let Predicates = [HasStdExtZba, IsRV64] in {
-// This pattern is put here due to the fact that i32 is not a legal type
-// in SDISel for RV64, which is not the case in GISel.
-def : Pat<(shl (i64 (zext i32:$rs1)), uimm5:$shamt),
- (SLLI_UW GPR:$rs1, uimm5:$shamt)>;
-} // Predicates = [HasStdExtZba, IsRV64]
-
// Ptr type used in patterns with GlobalISelEmitter
def PtrVT : PtrValueTypeByHwMode<XLenVT, 0>;
diff --git a/llvm/lib/Target/RISCV/RISCVInstrInfoZb.td b/llvm/lib/Target/RISCV/RISCVInstrInfoZb.td
index bba3ef6fb97e767..e67fc34a344adb8 100644
--- a/llvm/lib/Target/RISCV/RISCVInstrInfoZb.td
+++ b/llvm/lib/Target/RISCV/RISCVInstrInfoZb.td
@@ -847,9 +847,12 @@ def : Pat<(i32 (rotl GPR:$rs1, uimm5:$rs2)),
} // Predicates = [HasStdExtZbbOrZbkb, IsRV64]
let Predicates = [HasStdExtZba, IsRV64] in {
-def : Pat<(zext GPR:$src), (ADD_UW GPR:$src, (XLenVT X0))>;
+def : Pat<(shl (i64 (zext i32:$rs1)), uimm5:$shamt),
+ (SLLI_UW GPR:$rs1, uimm5:$shamt)>;
+
def : Pat<(i64 (add_non_imm12 (zext GPR:$rs1), GPR:$rs2)),
(ADD_UW GPR:$rs1, GPR:$rs2)>;
+def : Pat<(zext GPR:$src), (ADD_UW GPR:$src, (XLenVT X0))>;
foreach i = {1,2,3} in {
defvar shxadd = !cast<Instruction>("SH"#i#"ADD");
diff --git a/llvm/test/CodeGen/RISCV/rv64-legal-i32/rv64zba.ll b/llvm/test/CodeGen/RISCV/rv64-legal-i32/rv64zba.ll
index 54bb8ecec92bfbc..d1ba22842f55a57 100644
--- a/llvm/test/CodeGen/RISCV/rv64-legal-i32/rv64zba.ll
+++ b/llvm/test/CodeGen/RISCV/rv64-legal-i32/rv64zba.ll
@@ -45,6 +45,33 @@ define i128 @slliuw_2(i32 signext %0, ptr %1) {
ret i128 %5
}
+define i128 @slliuw_3(i32 signext %0, ptr %1) {
+; RV64I-LABEL: slliuw_3:
+; RV64I: # %bb.0:
+; RV64I-NEXT: addi a0, a0, 1
+; RV64I-NEXT: slli a0, a0, 32
+; RV64I-NEXT: srli a0, a0, 32
+; RV64I-NEXT: slli a0, a0, 4
+; RV64I-NEXT: add a1, a1, a0
+; RV64I-NEXT: ld a0, 0(a1)
+; RV64I-NEXT: ld a1, 8(a1)
+; RV64I-NEXT: ret
+;
+; RV64ZBA-LABEL: slliuw_3:
+; RV64ZBA: # %bb.0:
+; RV64ZBA-NEXT: addi a0, a0, 1
+; RV64ZBA-NEXT: slli.uw a0, a0, 4
+; RV64ZBA-NEXT: add a1, a1, a0
+; RV64ZBA-NEXT: ld a0, 0(a1)
+; RV64ZBA-NEXT: ld a1, 8(a1)
+; RV64ZBA-NEXT: ret
+ %add = add i32 %0, 1
+ %3 = zext i32 %add to i64
+ %4 = getelementptr inbounds i128, ptr %1, i64 %3
+ %5 = load i128, ptr %4
+ ret i128 %5
+}
+
define i64 @adduw(i64 %a, i64 %b) nounwind {
; RV64I-LABEL: adduw:
; RV64I: # %bb.0:
More information about the llvm-commits
mailing list