Skip to content

Commit

Permalink
[GlobalIsel][X86] Merge LZCNT 32-bit and 64-bit test coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
RKSimon committed Jun 2, 2023
1 parent c28506b commit 4c5355d
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 92 deletions.
72 changes: 0 additions & 72 deletions llvm/test/CodeGen/X86/GlobalISel/legalize-leading-zeros-32.mir

This file was deleted.

65 changes: 45 additions & 20 deletions llvm/test/CodeGen/X86/GlobalISel/legalize-leading-zeros.mir
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py UTC_ARGS: --version 2
# RUN: llc -mtriple=x86_64-linux-gnu -mattr=+lzcnt -run-pass=legalizer %s -o - | FileCheck %s
# RUN: llc -mtriple=x86_64-linux-gnu -mattr=+lzcnt -run-pass=legalizer %s -o - | FileCheck %s --check-prefixes=CHECK,X64
# RUN: llc -mtriple=i386-linux-gnu -mattr=+lzcnt -run-pass=legalizer -global-isel-abort=2 -pass-remarks-missed='gisel*' %s 2>%t -o - | FileCheck %s --check-prefixes=CHECK,X86
# RUN: FileCheck -check-prefix=ERR32 %s < %t

# ERR32: remark: <unknown>:0:0: unable to legalize instruction: %13:_(s32), %14:_(s1) = G_USUBE %8:_, %10:_, %12:_ (in function: test_ctlz35)
# ERR32: remark: <unknown>:0:0: unable to legalize instruction: %1:_(s64) = G_SELECT %6:_(s1), %9:_, %10:_ (in function: test_ctlz64)

# test count leading zeros for s16, s32, and s64

Expand All @@ -13,20 +18,32 @@ registers:
- { id: 1, class: _, preferred-register: '' }
body: |
bb.1:
; CHECK-LABEL: name: test_ctlz35
; CHECK: [[DEF:%[0-9]+]]:_(s35) = IMPLICIT_DEF
; CHECK-NEXT: [[ZEXT:%[0-9]+]]:_(s64) = G_ZEXT [[DEF]](s35)
; CHECK-NEXT: [[CTLZ:%[0-9]+]]:_(s64) = G_CTLZ [[ZEXT]](s64)
; CHECK-NEXT: [[C:%[0-9]+]]:_(s64) = G_CONSTANT i64 29
; CHECK-NEXT: [[SUB:%[0-9]+]]:_(s64) = G_SUB [[CTLZ]], [[C]]
; CHECK-NEXT: [[TRUNC:%[0-9]+]]:_(s35) = G_TRUNC [[SUB]](s64)
; CHECK-NEXT: [[COPY:%[0-9]+]]:_(s35) = COPY [[TRUNC]](s35)
; CHECK-NEXT: RET 0, implicit [[COPY]](s35)
; X64-LABEL: name: test_ctlz35
; X64: [[DEF:%[0-9]+]]:_(s35) = IMPLICIT_DEF
; X64-NEXT: [[ZEXT:%[0-9]+]]:_(s64) = G_ZEXT [[DEF]](s35)
; X64-NEXT: [[CTLZ:%[0-9]+]]:_(s64) = G_CTLZ [[ZEXT]](s64)
; X64-NEXT: [[C:%[0-9]+]]:_(s64) = G_CONSTANT i64 29
; X64-NEXT: [[SUB:%[0-9]+]]:_(s64) = G_SUB [[CTLZ]], [[C]]
; X64-NEXT: [[TRUNC:%[0-9]+]]:_(s35) = G_TRUNC [[SUB]](s64)
; X64-NEXT: [[COPY:%[0-9]+]]:_(s35) = COPY [[TRUNC]](s35)
; X64-NEXT: RET 0, implicit [[COPY]](s35)
; X86-LABEL: name: test_ctlz35
; X86: [[DEF:%[0-9]+]]:_(s35) = IMPLICIT_DEF
; X86-NEXT: [[ZEXT:%[0-9]+]]:_(s64) = G_ZEXT [[DEF]](s35)
; X86-NEXT: [[CTLZ:%[0-9]+]]:_(s64) = G_CTLZ [[ZEXT]](s64)
; X86-NEXT: [[C:%[0-9]+]]:_(s64) = G_CONSTANT i64 29
; X86-NEXT: [[UV:%[0-9]+]]:_(s32), [[UV1:%[0-9]+]]:_(s32) = G_UNMERGE_VALUES [[CTLZ]](s64)
; X86-NEXT: [[UV2:%[0-9]+]]:_(s32), [[UV3:%[0-9]+]]:_(s32) = G_UNMERGE_VALUES [[C]](s64)
; X86-NEXT: [[USUBO:%[0-9]+]]:_(s32), [[USUBO1:%[0-9]+]]:_(s1) = G_USUBO [[UV]], [[UV2]]
; X86-NEXT: [[USUBE:%[0-9]+]]:_(s32), [[USUBE1:%[0-9]+]]:_(s1) = G_USUBE [[UV1]], [[UV3]], [[USUBO1]]
; X86-NEXT: [[MV:%[0-9]+]]:_(s64) = G_MERGE_VALUES [[USUBO]](s32), [[USUBE]](s32)
; X86-NEXT: [[TRUNC:%[0-9]+]]:_(s35) = G_TRUNC [[MV]](s64)
; X86-NEXT: [[COPY:%[0-9]+]]:_(s35) = COPY [[TRUNC]](s35)
; X86-NEXT: RET 0, implicit [[COPY]](s35)
%0:_(s35) = IMPLICIT_DEF
%1:_(s35) = G_CTLZ %0
%2:_(s35) = COPY %1(s35)
RET 0, implicit %2
...
---
name: test_ctlz8
Expand All @@ -51,7 +68,6 @@ body: |
%1:_(s8) = G_CTLZ %0
%2:_(s8) = COPY %1(s8)
RET 0, implicit %2
...
---
name: test_ctlz64
Expand All @@ -63,16 +79,27 @@ registers:
- { id: 1, class: _, preferred-register: '' }
body: |
bb.1:
; CHECK-LABEL: name: test_ctlz64
; CHECK: [[DEF:%[0-9]+]]:_(s64) = IMPLICIT_DEF
; CHECK-NEXT: [[CTLZ:%[0-9]+]]:_(s64) = G_CTLZ [[DEF]](s64)
; CHECK-NEXT: [[COPY:%[0-9]+]]:_(s64) = COPY [[CTLZ]](s64)
; CHECK-NEXT: RET 0, implicit [[COPY]](s64)
; X64-LABEL: name: test_ctlz64
; X64: [[DEF:%[0-9]+]]:_(s64) = IMPLICIT_DEF
; X64-NEXT: [[CTLZ:%[0-9]+]]:_(s64) = G_CTLZ [[DEF]](s64)
; X64-NEXT: [[COPY:%[0-9]+]]:_(s64) = COPY [[CTLZ]](s64)
; X64-NEXT: RET 0, implicit [[COPY]](s64)
; X86-LABEL: name: test_ctlz64
; X86: [[DEF:%[0-9]+]]:_(s64) = IMPLICIT_DEF
; X86-NEXT: [[UV:%[0-9]+]]:_(s32), [[UV1:%[0-9]+]]:_(s32) = G_UNMERGE_VALUES [[DEF]](s64)
; X86-NEXT: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 0
; X86-NEXT: [[ICMP:%[0-9]+]]:_(s1) = G_ICMP intpred(eq), [[UV1]](s32), [[C]]
; X86-NEXT: [[CTLZ:%[0-9]+]]:_(s64) = G_CTLZ [[UV]](s32)
; X86-NEXT: [[C1:%[0-9]+]]:_(s64) = G_CONSTANT i64 32
; X86-NEXT: [[ADD:%[0-9]+]]:_(s64) = G_ADD [[CTLZ]], [[C1]]
; X86-NEXT: [[CTLZ_ZERO_UNDEF:%[0-9]+]]:_(s64) = G_CTLZ_ZERO_UNDEF [[UV1]](s32)
; X86-NEXT: [[SELECT:%[0-9]+]]:_(s64) = G_SELECT [[ICMP]](s1), [[ADD]], [[CTLZ_ZERO_UNDEF]]
; X86-NEXT: [[COPY:%[0-9]+]]:_(s64) = COPY [[SELECT]](s64)
; X86-NEXT: RET 0, implicit [[COPY]](s64)
%0:_(s64) = IMPLICIT_DEF
%1:_(s64) = G_CTLZ %0
%2:_(s64) = COPY %1(s64)
RET 0, implicit %2
...
---
name: test_ctlz32
Expand All @@ -93,7 +120,6 @@ body: |
%1:_(s32) = G_CTLZ %0
%2:_(s32) = COPY %1(s32)
RET 0, implicit %2
...
---
name: test_ctlz16
Expand All @@ -114,5 +140,4 @@ body: |
%1:_(s16) = G_CTLZ %0
%2:_(s16) = COPY %1(s16)
RET 0, implicit %2
...

0 comments on commit 4c5355d

Please sign in to comment.