[llvm] 24f49de - [GlobalIsel][X86] Legalize G_FREEZE
Thorsten Schütt via llvm-commits
llvm-commits at lists.llvm.org
Fri Jun 9 22:33:09 PDT 2023
Author: Thorsten Schütt
Date: 2023-06-10T07:33:02+02:00
New Revision: 24f49deacfb51347a1c7072a5015a654e66d01d2
URL: https://github.com/llvm/llvm-project/commit/24f49deacfb51347a1c7072a5015a654e66d01d2
DIFF: https://github.com/llvm/llvm-project/commit/24f49deacfb51347a1c7072a5015a654e66d01d2.diff
LOG: [GlobalIsel][X86] Legalize G_FREEZE
Reviewed By: arsenm
Differential Revision: https://reviews.llvm.org/D152501
Added:
llvm/test/CodeGen/X86/GlobalISel/legalize-freeze.mir
Modified:
llvm/lib/Target/X86/X86LegalizerInfo.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Target/X86/X86LegalizerInfo.cpp b/llvm/lib/Target/X86/X86LegalizerInfo.cpp
index 325b7b6fad841..ac5f66055733a 100644
--- a/llvm/lib/Target/X86/X86LegalizerInfo.cpp
+++ b/llvm/lib/Target/X86/X86LegalizerInfo.cpp
@@ -348,6 +348,11 @@ X86LegalizerInfo::X86LegalizerInfo(const X86Subtarget &STI,
.minScalar(0, LLT::scalar(32))
.libcall();
+ getActionDefinitionsBuilder(G_FREEZE)
+ .legalFor({s8, s16, s32, s64, p0})
+ .widenScalarToNextPow2(0, /*Min=*/8)
+ .clampScalar(0, s8, sMaxScalar);
+
setLegalizerInfo32bit();
setLegalizerInfo64bit();
setLegalizerInfoSSE1();
diff --git a/llvm/test/CodeGen/X86/GlobalISel/legalize-freeze.mir b/llvm/test/CodeGen/X86/GlobalISel/legalize-freeze.mir
new file mode 100644
index 0000000000000..e3d58008bb4bf
--- /dev/null
+++ b/llvm/test/CodeGen/X86/GlobalISel/legalize-freeze.mir
@@ -0,0 +1,98 @@
+# NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py UTC_ARGS: --version 2
+# RUN: llc -verify-machineinstrs -mtriple=x86_64-linux-gnu -run-pass=legalizer %s -o - | FileCheck %s
+
+# test freeze
+
+...
+---
+name: test_freezep0
+body: |
+ bb.1:
+ ; CHECK-LABEL: name: test_freezep0
+ ; CHECK: [[DEF:%[0-9]+]]:_(p0) = IMPLICIT_DEF
+ ; CHECK-NEXT: [[FREEZE:%[0-9]+]]:_(p0) = G_FREEZE [[DEF]]
+ ; CHECK-NEXT: [[COPY:%[0-9]+]]:_(p0) = COPY [[FREEZE]](p0)
+ ; CHECK-NEXT: RET 0, implicit [[COPY]](p0)
+ %0:_(p0) = IMPLICIT_DEF
+ %1:_(p0) = G_FREEZE %0
+ %2:_(p0) = COPY %1(p0)
+ RET 0, implicit %2
+
+...
+---
+name: test_freeze64
+body: |
+ bb.1:
+ ; CHECK-LABEL: name: test_freeze64
+ ; CHECK: [[DEF:%[0-9]+]]:_(s64) = IMPLICIT_DEF
+ ; CHECK-NEXT: [[FREEZE:%[0-9]+]]:_(s64) = G_FREEZE [[DEF]]
+ ; CHECK-NEXT: [[COPY:%[0-9]+]]:_(s64) = COPY [[FREEZE]](s64)
+ ; CHECK-NEXT: RET 0, implicit [[COPY]](s64)
+ %0:_(s64) = IMPLICIT_DEF
+ %1:_(s64) = G_FREEZE %0
+ %2:_(s64) = COPY %1(s64)
+ RET 0, implicit %2
+
+...
+---
+name: test_freeze48
+body: |
+ bb.1:
+ ; CHECK-LABEL: name: test_freeze48
+ ; CHECK: [[DEF:%[0-9]+]]:_(s48) = IMPLICIT_DEF
+ ; CHECK-NEXT: [[ANYEXT:%[0-9]+]]:_(s64) = G_ANYEXT [[DEF]](s48)
+ ; CHECK-NEXT: [[FREEZE:%[0-9]+]]:_(s64) = G_FREEZE [[ANYEXT]]
+ ; CHECK-NEXT: [[TRUNC:%[0-9]+]]:_(s48) = G_TRUNC [[FREEZE]](s64)
+ ; CHECK-NEXT: [[COPY:%[0-9]+]]:_(s48) = COPY [[TRUNC]](s48)
+ ; CHECK-NEXT: RET 0, implicit [[COPY]](s48)
+ %0:_(s48) = IMPLICIT_DEF
+ %1:_(s48) = G_FREEZE %0
+ %2:_(s48) = COPY %1(s48)
+ RET 0, implicit %2
+
+...
+---
+name: test_freeze32
+body: |
+ bb.1:
+ ; CHECK-LABEL: name: test_freeze32
+ ; CHECK: [[DEF:%[0-9]+]]:_(s32) = IMPLICIT_DEF
+ ; CHECK-NEXT: [[FREEZE:%[0-9]+]]:_(s32) = G_FREEZE [[DEF]]
+ ; CHECK-NEXT: [[COPY:%[0-9]+]]:_(s32) = COPY [[FREEZE]](s32)
+ ; CHECK-NEXT: RET 0, implicit [[COPY]](s32)
+ %0:_(s32) = IMPLICIT_DEF
+ %1:_(s32) = G_FREEZE %0
+ %2:_(s32) = COPY %1(s32)
+ RET 0, implicit %2
+
+...
+---
+name: test_freeze16
+body: |
+ bb.1:
+ ; CHECK-LABEL: name: test_freeze16
+ ; CHECK: [[DEF:%[0-9]+]]:_(s16) = IMPLICIT_DEF
+ ; CHECK-NEXT: [[FREEZE:%[0-9]+]]:_(s16) = G_FREEZE [[DEF]]
+ ; CHECK-NEXT: [[COPY:%[0-9]+]]:_(s16) = COPY [[FREEZE]](s16)
+ ; CHECK-NEXT: RET 0, implicit [[COPY]](s16)
+ %0:_(s16) = IMPLICIT_DEF
+ %1:_(s16) = G_FREEZE %0
+ %2:_(s16) = COPY %1(s16)
+ RET 0, implicit %2
+
+...
+---
+name: test_freeze8
+body: |
+ bb.1:
+ ; CHECK-LABEL: name: test_freeze8
+ ; CHECK: [[DEF:%[0-9]+]]:_(s8) = IMPLICIT_DEF
+ ; CHECK-NEXT: [[FREEZE:%[0-9]+]]:_(s8) = G_FREEZE [[DEF]]
+ ; CHECK-NEXT: [[COPY:%[0-9]+]]:_(s8) = COPY [[FREEZE]](s8)
+ ; CHECK-NEXT: RET 0, implicit [[COPY]](s8)
+ %0:_(s8) = IMPLICIT_DEF
+ %1:_(s8) = G_FREEZE %0
+ %2:_(s8) = COPY %1(s8)
+ RET 0, implicit %2
+
+...
More information about the llvm-commits
mailing list