[llvm] 4fcbe5f - Revert rG2f9a4d308d4517eee85e373bc09920f85f91fdcd "[GlobalISel][X86] Add G_CTLZ_ZERO_UNDEF legalization handling"
Simon Pilgrim via llvm-commits
llvm-commits at lists.llvm.org
Fri Jun 2 10:43:27 PDT 2023
Author: Simon Pilgrim
Date: 2023-06-02T18:43:11+01:00
New Revision: 4fcbe5fbeda15220bbbd8f4dbd6909a66a19b779
URL: https://github.com/llvm/llvm-project/commit/4fcbe5fbeda15220bbbd8f4dbd6909a66a19b779
DIFF: https://github.com/llvm/llvm-project/commit/4fcbe5fbeda15220bbbd8f4dbd6909a66a19b779.diff
LOG: Revert rG2f9a4d308d4517eee85e373bc09920f85f91fdcd "[GlobalISel][X86] Add G_CTLZ_ZERO_UNDEF legalization handling"
Unintentional commit - G_CTLZ_ZERO_UNDEF will have to be custom handled as BSR needs the bits flipping (and we don't have a pattern for that yet).
Added:
Modified:
llvm/lib/Target/X86/X86LegalizerInfo.cpp
Removed:
llvm/test/CodeGen/X86/GlobalISel/legalize-leading-zeros-undef.mir
################################################################################
diff --git a/llvm/lib/Target/X86/X86LegalizerInfo.cpp b/llvm/lib/Target/X86/X86LegalizerInfo.cpp
index 4a424925b0b40..4fbcd00e7cef4 100644
--- a/llvm/lib/Target/X86/X86LegalizerInfo.cpp
+++ b/llvm/lib/Target/X86/X86LegalizerInfo.cpp
@@ -153,10 +153,10 @@ X86LegalizerInfo::X86LegalizerInfo(const X86Subtarget &STI,
.widenScalarToNextPow2(1, /*Min=*/16)
.clampScalar(1, s16, sMaxScalar);
- // count leading zeros
- getActionDefinitionsBuilder({G_CTLZ_ZERO_UNDEF, G_CTLZ})
+ // count leading zeros (LZCNT)
+ getActionDefinitionsBuilder(G_CTLZ)
.legalIf([=](const LegalityQuery &Query) -> bool {
- return (Query.Opcode == G_CTLZ_ZERO_UNDEF || Subtarget.hasLZCNT()) &&
+ return Subtarget.hasLZCNT() &&
(typePairInSet(0, 1, {{s16, s16}, {s32, s32}})(Query) ||
(Is64Bit && typePairInSet(0, 1, {{s64, s64}})(Query)));
})
diff --git a/llvm/test/CodeGen/X86/GlobalISel/legalize-leading-zeros-undef.mir b/llvm/test/CodeGen/X86/GlobalISel/legalize-leading-zeros-undef.mir
deleted file mode 100644
index 3d45750846bf7..0000000000000
--- a/llvm/test/CodeGen/X86/GlobalISel/legalize-leading-zeros-undef.mir
+++ /dev/null
@@ -1,143 +0,0 @@
-# NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py UTC_ARGS: --version 2
-# RUN: llc -mtriple=x86_64-linux-gnu -run-pass=legalizer %s -o - | FileCheck %s --check-prefixes=CHECK,X64
-# RUN: llc -mtriple=i386-linux-gnu -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
-
----
-name: test_ctlz35
-alignment: 16
-legalized: false
-regBankSelected: false
-registers:
- - { id: 0, class: _, preferred-register: '' }
- - { id: 1, class: _, preferred-register: '' }
-body: |
- bb.1:
- ; 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_ZERO_UNDEF:%[0-9]+]]:_(s64) = G_CTLZ_ZERO_UNDEF [[ZEXT]](s64)
- ; X64-NEXT: [[C:%[0-9]+]]:_(s64) = G_CONSTANT i64 29
- ; X64-NEXT: [[SUB:%[0-9]+]]:_(s64) = G_SUB [[CTLZ_ZERO_UNDEF]], [[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_ZERO_UNDEF:%[0-9]+]]:_(s64) = G_CTLZ_ZERO_UNDEF [[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_ZERO_UNDEF]](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_ZERO_UNDEF %0
- %2:_(s35) = COPY %1(s35)
- RET 0, implicit %2
-...
----
-name: test_ctlz8
-alignment: 16
-legalized: false
-regBankSelected: false
-registers:
- - { id: 0, class: _, preferred-register: '' }
- - { id: 1, class: _, preferred-register: '' }
-body: |
- bb.1:
- ; CHECK-LABEL: name: test_ctlz8
- ; CHECK: [[DEF:%[0-9]+]]:_(s8) = IMPLICIT_DEF
- ; CHECK-NEXT: [[ZEXT:%[0-9]+]]:_(s16) = G_ZEXT [[DEF]](s8)
- ; CHECK-NEXT: [[CTLZ_ZERO_UNDEF:%[0-9]+]]:_(s16) = G_CTLZ_ZERO_UNDEF [[ZEXT]](s16)
- ; CHECK-NEXT: [[C:%[0-9]+]]:_(s16) = G_CONSTANT i16 8
- ; CHECK-NEXT: [[SUB:%[0-9]+]]:_(s16) = G_SUB [[CTLZ_ZERO_UNDEF]], [[C]]
- ; CHECK-NEXT: [[TRUNC:%[0-9]+]]:_(s8) = G_TRUNC [[SUB]](s16)
- ; CHECK-NEXT: [[COPY:%[0-9]+]]:_(s8) = COPY [[TRUNC]](s8)
- ; CHECK-NEXT: RET 0, implicit [[COPY]](s8)
- %0:_(s8) = IMPLICIT_DEF
- %1:_(s8) = G_CTLZ_ZERO_UNDEF %0
- %2:_(s8) = COPY %1(s8)
- RET 0, implicit %2
-...
----
-name: test_ctlz64
-alignment: 16
-legalized: false
-regBankSelected: false
-registers:
- - { id: 0, class: _, preferred-register: '' }
- - { id: 1, class: _, preferred-register: '' }
-body: |
- bb.1:
- ; X64-LABEL: name: test_ctlz64
- ; X64: [[DEF:%[0-9]+]]:_(s64) = IMPLICIT_DEF
- ; X64-NEXT: [[CTLZ_ZERO_UNDEF:%[0-9]+]]:_(s64) = G_CTLZ_ZERO_UNDEF [[DEF]](s64)
- ; X64-NEXT: [[COPY:%[0-9]+]]:_(s64) = COPY [[CTLZ_ZERO_UNDEF]](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_ZERO_UNDEF:%[0-9]+]]:_(s64) = G_CTLZ_ZERO_UNDEF [[UV]](s32)
- ; X86-NEXT: [[C1:%[0-9]+]]:_(s64) = G_CONSTANT i64 32
- ; X86-NEXT: [[ADD:%[0-9]+]]:_(s64) = G_ADD [[CTLZ_ZERO_UNDEF]], [[C1]]
- ; X86-NEXT: [[CTLZ_ZERO_UNDEF1:%[0-9]+]]:_(s64) = G_CTLZ_ZERO_UNDEF [[UV1]](s32)
- ; X86-NEXT: [[SELECT:%[0-9]+]]:_(s64) = G_SELECT [[ICMP]](s1), [[ADD]], [[CTLZ_ZERO_UNDEF1]]
- ; X86-NEXT: [[COPY:%[0-9]+]]:_(s64) = COPY [[SELECT]](s64)
- ; X86-NEXT: RET 0, implicit [[COPY]](s64)
- %0:_(s64) = IMPLICIT_DEF
- %1:_(s64) = G_CTLZ_ZERO_UNDEF %0
- %2:_(s64) = COPY %1(s64)
- RET 0, implicit %2
-...
----
-name: test_ctlz32
-alignment: 16
-legalized: false
-regBankSelected: false
-registers:
- - { id: 0, class: _, preferred-register: '' }
- - { id: 1, class: _, preferred-register: '' }
-body: |
- bb.1:
- ; CHECK-LABEL: name: test_ctlz32
- ; CHECK: [[DEF:%[0-9]+]]:_(s32) = IMPLICIT_DEF
- ; CHECK-NEXT: [[CTLZ_ZERO_UNDEF:%[0-9]+]]:_(s32) = G_CTLZ_ZERO_UNDEF [[DEF]](s32)
- ; CHECK-NEXT: [[COPY:%[0-9]+]]:_(s32) = COPY [[CTLZ_ZERO_UNDEF]](s32)
- ; CHECK-NEXT: RET 0, implicit [[COPY]](s32)
- %0:_(s32) = IMPLICIT_DEF
- %1:_(s32) = G_CTLZ_ZERO_UNDEF %0
- %2:_(s32) = COPY %1(s32)
- RET 0, implicit %2
-...
----
-name: test_ctlz16
-alignment: 16
-legalized: false
-regBankSelected: false
-registers:
- - { id: 0, class: _, preferred-register: '' }
- - { id: 1, class: _, preferred-register: '' }
-body: |
- bb.1:
- ; CHECK-LABEL: name: test_ctlz16
- ; CHECK: [[DEF:%[0-9]+]]:_(s16) = IMPLICIT_DEF
- ; CHECK-NEXT: [[CTLZ_ZERO_UNDEF:%[0-9]+]]:_(s16) = G_CTLZ_ZERO_UNDEF [[DEF]](s16)
- ; CHECK-NEXT: [[COPY:%[0-9]+]]:_(s16) = COPY [[CTLZ_ZERO_UNDEF]](s16)
- ; CHECK-NEXT: RET 0, implicit [[COPY]](s16)
- %0:_(s16) = IMPLICIT_DEF
- %1:_(s16) = G_CTLZ_ZERO_UNDEF %0
- %2:_(s16) = COPY %1(s16)
- RET 0, implicit %2
-...
More information about the llvm-commits
mailing list