Skip to content

Commit

Permalink
[X86][GlobalISel] Fix referencing nonexistent operand in G_ICMP (#86221)
Browse files Browse the repository at this point in the history
Fixes #86203
  • Loading branch information
e-kud authored Mar 25, 2024
1 parent 0bdb883 commit fb39456
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 2 deletions.
3 changes: 1 addition & 2 deletions llvm/lib/Target/X86/GISel/X86LegalizerInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
25 changes: 25 additions & 0 deletions llvm/test/CodeGen/X86/GlobalISel/legalize-icmp-vec.mir
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# 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=ILLEGAL %s < %t

# ILLEGAL: 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)

# PR86203
---
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
...

0 comments on commit fb39456

Please sign in to comment.