diff --git a/llvm/lib/Target/RISCV/GISel/RISCVLegalizerInfo.cpp b/llvm/lib/Target/RISCV/GISel/RISCVLegalizerInfo.cpp --- a/llvm/lib/Target/RISCV/GISel/RISCVLegalizerInfo.cpp +++ b/llvm/lib/Target/RISCV/GISel/RISCVLegalizerInfo.cpp @@ -69,7 +69,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); diff --git a/llvm/test/CodeGen/RISCV/GlobalISel/legalizer/rv32/legalize-icmp.mir b/llvm/test/CodeGen/RISCV/GlobalISel/legalizer/rv32/legalize-icmp.mir --- a/llvm/test/CodeGen/RISCV/GlobalISel/legalizer/rv32/legalize-icmp.mir +++ b/llvm/test/CodeGen/RISCV/GlobalISel/legalizer/rv32/legalize-icmp.mir @@ -1529,3 +1529,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 + +... diff --git a/llvm/test/CodeGen/RISCV/GlobalISel/legalizer/rv64/legalize-icmp.mir b/llvm/test/CodeGen/RISCV/GlobalISel/legalizer/rv64/legalize-icmp.mir --- a/llvm/test/CodeGen/RISCV/GlobalISel/legalizer/rv64/legalize-icmp.mir +++ b/llvm/test/CodeGen/RISCV/GlobalISel/legalizer/rv64/legalize-icmp.mir @@ -1761,3 +1761,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 + +...