[PATCH] D157823: [RISCV][GISel] Make G_ICMP of pointers legal.
Craig Topper via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Sun Aug 13 11:58:21 PDT 2023
craig.topper created this revision.
craig.topper added reviewers: nitinjohnraj, arsenm, asb.
Herald added subscribers: jobnoorman, luke, VincentWu, vkmr, frasercrmck, luismarques, apazos, sameer.abuasal, s.egerton, Jim, benna, psnobl, jocewei, PkmX, the_o, brucehoult, MartinMosbeck, rogfer01, edward-jones, zzheng, jrtc27, shiva0217, kito-cheng, niosHD, sabuasal, simoncook, johnrusso, rbar, hiraditya, arichardson.
Herald added a project: All.
craig.topper requested review of this revision.
Herald added subscribers: wangpc, eopXD, MaskRay, wdng.
Herald added a project: LLVM.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D157823
Files:
llvm/lib/Target/RISCV/GISel/RISCVLegalizerInfo.cpp
llvm/test/CodeGen/RISCV/GlobalISel/legalizer/rv32/legalize-icmp.mir
llvm/test/CodeGen/RISCV/GlobalISel/legalizer/rv64/legalize-icmp.mir
Index: llvm/test/CodeGen/RISCV/GlobalISel/legalizer/rv64/legalize-icmp.mir
===================================================================
--- llvm/test/CodeGen/RISCV/GlobalISel/legalizer/rv64/legalize-icmp.mir
+++ llvm/test/CodeGen/RISCV/GlobalISel/legalizer/rv64/legalize-icmp.mir
@@ -1857,3 +1857,21 @@
PseudoRET implicit $x10
...
+---
+name: cmp_ne_ptr
+body: |
+ bb.0.entry:
+ ; CHECK-LABEL: name: cmp_ne_ptr
+ ; CHECK: [[COPY:%[0-9]+]]:_(p0) = COPY $x10
+ ; CHECK-NEXT: [[COPY1:%[0-9]+]]:_(p0) = COPY $x11
+ ; CHECK-NEXT: [[ICMP:%[0-9]+]]:_(s64) = G_ICMP intpred(ne), [[COPY]](p0), [[COPY1]]
+ ; CHECK-NEXT: $x10 = COPY [[ICMP]](s64)
+ ; CHECK-NEXT: PseudoRET implicit $x10
+ %0:_(p0) = COPY $x10
+ %1:_(p0) = COPY $x11
+ %2:_(s1) = G_ICMP intpred(ne), %0(p0), %1
+ %3:_(s64) = G_ANYEXT %2(s1)
+ $x10 = COPY %3(s64)
+ PseudoRET implicit $x10
+
+...
Index: llvm/test/CodeGen/RISCV/GlobalISel/legalizer/rv32/legalize-icmp.mir
===================================================================
--- llvm/test/CodeGen/RISCV/GlobalISel/legalizer/rv32/legalize-icmp.mir
+++ llvm/test/CodeGen/RISCV/GlobalISel/legalizer/rv32/legalize-icmp.mir
@@ -1625,3 +1625,21 @@
PseudoRET implicit $x10
...
+---
+name: cmp_eq_ptr
+body: |
+ bb.0.entry:
+ ; CHECK-LABEL: name: cmp_eq_ptr
+ ; CHECK: [[COPY:%[0-9]+]]:_(p0) = COPY $x10
+ ; CHECK-NEXT: [[COPY1:%[0-9]+]]:_(p0) = COPY $x11
+ ; CHECK-NEXT: [[ICMP:%[0-9]+]]:_(s32) = G_ICMP intpred(eq), [[COPY]](p0), [[COPY1]]
+ ; CHECK-NEXT: $x10 = COPY [[ICMP]](s32)
+ ; CHECK-NEXT: PseudoRET implicit $x10
+ %0:_(p0) = COPY $x10
+ %1:_(p0) = COPY $x11
+ %2:_(s1) = G_ICMP intpred(eq), %0(p0), %1
+ %3:_(s32) = G_ANYEXT %2(s1)
+ $x10 = COPY %3(s32)
+ 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;
@@ -86,7 +87,7 @@
.clampScalar(0, XLenLLT, XLenLLT);
getActionDefinitionsBuilder(G_ICMP)
- .legalFor({{XLenLLT, XLenLLT}})
+ .legalFor({{XLenLLT, XLenLLT}, {XLenLLT, p0}})
.widenScalarToNextPow2(1)
.clampScalar(1, XLenLLT, XLenLLT)
.clampScalar(0, XLenLLT, XLenLLT);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D157823.549738.patch
Type: text/x-patch
Size: 2645 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230813/ba8a8826/attachment.bin>
More information about the llvm-commits
mailing list