[PATCH] D157822: [RISCV][GISel] Make G_CONSTANT of pointers legal.

Craig Topper via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Aug 14 10:11:56 PDT 2023


This revision was automatically updated to reflect the committed changes.
Closed by commit rG1fa858d987ec: [RISCV][GISel] Make G_CONSTANT of pointers legal. (authored by craig.topper).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D157822/new/

https://reviews.llvm.org/D157822

Files:
  llvm/lib/Target/RISCV/GISel/RISCVLegalizerInfo.cpp
  llvm/test/CodeGen/RISCV/GlobalISel/legalizer/rv32/legalize-const.mir
  llvm/test/CodeGen/RISCV/GlobalISel/legalizer/rv64/legalize-const.mir


Index: llvm/test/CodeGen/RISCV/GlobalISel/legalizer/rv64/legalize-const.mir
===================================================================
--- llvm/test/CodeGen/RISCV/GlobalISel/legalizer/rv64/legalize-const.mir
+++ llvm/test/CodeGen/RISCV/GlobalISel/legalizer/rv64/legalize-const.mir
@@ -125,3 +125,16 @@
     PseudoRET implicit $x10, implicit $x11, implicit $x12
 
 ...
+---
+name:            const_null
+body:             |
+  bb.0.entry:
+    ; CHECK-LABEL: name: const_null
+    ; CHECK: [[C:%[0-9]+]]:_(p0) = G_CONSTANT i64 0
+    ; CHECK-NEXT: $x10 = COPY [[C]](p0)
+    ; CHECK-NEXT: PseudoRET implicit $x10
+    %0:_(p0) = G_CONSTANT i64 0
+    $x10 = COPY %0(p0)
+    PseudoRET implicit $x10
+
+...
Index: llvm/test/CodeGen/RISCV/GlobalISel/legalizer/rv32/legalize-const.mir
===================================================================
--- llvm/test/CodeGen/RISCV/GlobalISel/legalizer/rv32/legalize-const.mir
+++ llvm/test/CodeGen/RISCV/GlobalISel/legalizer/rv32/legalize-const.mir
@@ -111,3 +111,16 @@
     PseudoRET implicit $x10, implicit $x11, implicit $x12
 
 ...
+---
+name:            const_null
+body:             |
+  bb.0.entry:
+    ; CHECK-LABEL: name: const_null
+    ; CHECK: [[C:%[0-9]+]]:_(p0) = G_CONSTANT i32 0
+    ; CHECK-NEXT: $x10 = COPY [[C]](p0)
+    ; CHECK-NEXT: PseudoRET implicit $x10
+    %0:_(p0) = G_CONSTANT i32 0
+    $x10 = COPY %0(p0)
+    PseudoRET implicit $x10
+
+...
Index: llvm/lib/Target/RISCV/GISel/RISCVLegalizerInfo.cpp
===================================================================
--- llvm/lib/Target/RISCV/GISel/RISCVLegalizerInfo.cpp
+++ llvm/lib/Target/RISCV/GISel/RISCVLegalizerInfo.cpp
@@ -22,6 +22,7 @@
 RISCVLegalizerInfo::RISCVLegalizerInfo(const RISCVSubtarget &ST) {
   const unsigned XLen = ST.getXLen();
   const LLT XLenLLT = LLT::scalar(XLen);
+  const LLT p0 = LLT::pointer(0, XLen);
 
   using namespace TargetOpcode;
 
@@ -81,7 +82,7 @@
   }
 
   getActionDefinitionsBuilder({G_CONSTANT, G_IMPLICIT_DEF})
-      .legalFor({XLenLLT})
+      .legalFor({XLenLLT, p0})
       .widenScalarToNextPow2(0)
       .clampScalar(0, XLenLLT, XLenLLT);
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D157822.550010.patch
Type: text/x-patch
Size: 2132 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230814/9eba1a2c/attachment.bin>


More information about the llvm-commits mailing list