[llvm] [X86][GlobalISel] Fix referencing nonexistent operand in G_ICMP (PR #86221)
Evgenii Kudriashov via llvm-commits
llvm-commits at lists.llvm.org
Thu Mar 21 17:06:22 PDT 2024
https://github.com/e-kud created https://github.com/llvm/llvm-project/pull/86221
Fixes #86203
>From 5942a560f5b3309ec9ee93e89af73e972b993dd2 Mon Sep 17 00:00:00 2001
From: Evgenii Kudriashov <evgenii.kudriashov at intel.com>
Date: Thu, 21 Mar 2024 16:59:34 -0700
Subject: [PATCH] [X86][GlobalISel] Fix referencing nonexistent operand in
G_ICMP
---
.../lib/Target/X86/GISel/X86LegalizerInfo.cpp | 3 +--
.../X86/GlobalISel/legalize-icmp-vec.mir | 24 +++++++++++++++++++
2 files changed, 25 insertions(+), 2 deletions(-)
create mode 100644 llvm/test/CodeGen/X86/GlobalISel/legalize-icmp-vec.mir
diff --git a/llvm/lib/Target/X86/GISel/X86LegalizerInfo.cpp b/llvm/lib/Target/X86/GISel/X86LegalizerInfo.cpp
index 06389842ebb1ed..07041cc5b0491c 100644
--- a/llvm/lib/Target/X86/GISel/X86LegalizerInfo.cpp
+++ b/llvm/lib/Target/X86/GISel/X86LegalizerInfo.cpp
@@ -259,8 +259,7 @@ X86LegalizerInfo::X86LegalizerInfo(const X86Subtarget &STI,
getActionDefinitionsBuilder(G_ICMP)
.legalForCartesianProduct({s8}, Is64Bit ? IntTypes64 : IntTypes32)
.clampScalar(0, s8, s8)
- .clampScalar(1, s8, sMaxScalar)
- .scalarSameSizeAs(2, 1);
+ .clampScalar(1, s8, sMaxScalar);
// bswap
getActionDefinitionsBuilder(G_BSWAP)
diff --git a/llvm/test/CodeGen/X86/GlobalISel/legalize-icmp-vec.mir b/llvm/test/CodeGen/X86/GlobalISel/legalize-icmp-vec.mir
new file mode 100644
index 00000000000000..e18527ec681fe4
--- /dev/null
+++ b/llvm/test/CodeGen/X86/GlobalISel/legalize-icmp-vec.mir
@@ -0,0 +1,24 @@
+# RUN: llc -mtriple=x86_64-linux-gnu -run-pass=legalizer -global-isel-abort=2 -pass-remarks-missed='gisel*' %s -o - 2>%t | FileCheck %s
+# RUN: FileCheck -check-prefix=NOTLEGAL %s < %t
+
+# NOTLEGAL: remark: <unknown>:0:0: unable to legalize instruction: %2:_(<4 x s1>) = G_ICMP intpred(sle), %0:_(<4 x s64>), %1:_ (in function: test_icmp_v4i64)
+
+---
+name: test_icmp_v4i64
+tracksRegLiveness: true
+body: |
+ bb.1:
+ ; CHECK-LABEL: name: test_icmp_v4i64
+ ; CHECK: [[DEF:%[0-9]+]]:_(<4 x s64>) = G_IMPLICIT_DEF
+ ; CHECK-NEXT: [[DEF1:%[0-9]+]]:_(<4 x s64>) = G_IMPLICIT_DEF
+ ; CHECK-NEXT: [[ICMP:%[0-9]+]]:_(<4 x s1>) = G_ICMP intpred(sle), [[DEF]](<4 x s64>), [[DEF1]]
+ ; CHECK-NEXT: [[ANYEXT:%[0-9]+]]:_(<4 x s32>) = G_ANYEXT [[ICMP]](<4 x s1>)
+ ; CHECK-NEXT: $xmm0 = COPY [[ANYEXT]](<4 x s32>)
+ ; CHECK-NEXT: RET 0, implicit $xmm0
+ %0:_(<4 x s64>) = G_IMPLICIT_DEF
+ %1:_(<4 x s64>) = G_IMPLICIT_DEF
+ %3:_(<4 x s1>) = G_ICMP intpred(sle), %0(<4 x s64>), %1
+ %4:_(<4 x s32>) = G_ANYEXT %3(<4 x s1>)
+ $xmm0 = COPY %4(<4 x s32>)
+ RET 0, implicit $xmm0
+...
More information about the llvm-commits
mailing list