[PATCH] D153684: [GlobalIsel][X86]] Legalize G_CONSTANT_FOLD_BARRIER
Thorsten via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Jun 23 22:37:36 PDT 2023
tschuett created this revision.
Herald added subscribers: pengfei, hiraditya.
Herald added a project: All.
tschuett requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D153684
Files:
llvm/lib/Target/X86/X86LegalizerInfo.cpp
llvm/test/CodeGen/X86/GlobalISel/legalize-constant-fold.mir
Index: llvm/test/CodeGen/X86/GlobalISel/legalize-constant-fold.mir
===================================================================
--- /dev/null
+++ llvm/test/CodeGen/X86/GlobalISel/legalize-constant-fold.mir
@@ -0,0 +1,66 @@
+# NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py UTC_ARGS: --version 2
+# RUN: llc -mtriple=i386-linux-gnu -run-pass=legalizer %s -o - | FileCheck %s --check-prefix=X86-32
+
+# test constant fold barrier
+
+...
+---
+name: test_fold64
+body: |
+ bb.0:
+ ; X86-32-LABEL: name: test_fold64
+ ; X86-32: [[DEF:%[0-9]+]]:_(s64) = IMPLICIT_DEF
+ ; X86-32-NEXT: [[CONSTANT_FOLD_BARRIER:%[0-9]+]]:_(s64) = G_CONSTANT_FOLD_BARRIER [[DEF]]
+ ; X86-32-NEXT: [[COPY:%[0-9]+]]:_(s64) = COPY [[CONSTANT_FOLD_BARRIER]](s64)
+ ; X86-32-NEXT: RET 0, implicit [[COPY]](s64)
+ %0:_(s64) = IMPLICIT_DEF
+ %1:_(s64) = G_CONSTANT_FOLD_BARRIER %0
+ %2:_(s64) = COPY %1(s64)
+ RET 0, implicit %2
+
+...
+---
+name: test_fold32
+body: |
+ bb.0:
+ ; X86-32-LABEL: name: test_fold32
+ ; X86-32: [[DEF:%[0-9]+]]:_(s32) = IMPLICIT_DEF
+ ; X86-32-NEXT: [[CONSTANT_FOLD_BARRIER:%[0-9]+]]:_(s32) = G_CONSTANT_FOLD_BARRIER [[DEF]]
+ ; X86-32-NEXT: [[COPY:%[0-9]+]]:_(s32) = COPY [[CONSTANT_FOLD_BARRIER]](s32)
+ ; X86-32-NEXT: RET 0, implicit [[COPY]](s32)
+ %0:_(s32) = IMPLICIT_DEF
+ %1:_(s32) = G_CONSTANT_FOLD_BARRIER %0
+ %2:_(s32) = COPY %1(s32)
+ RET 0, implicit %2
+
+...
+---
+name: test_fold16
+body: |
+ bb.0:
+ ; X86-32-LABEL: name: test_fold16
+ ; X86-32: [[DEF:%[0-9]+]]:_(s16) = IMPLICIT_DEF
+ ; X86-32-NEXT: [[CONSTANT_FOLD_BARRIER:%[0-9]+]]:_(s16) = G_CONSTANT_FOLD_BARRIER [[DEF]]
+ ; X86-32-NEXT: [[COPY:%[0-9]+]]:_(s16) = COPY [[CONSTANT_FOLD_BARRIER]](s16)
+ ; X86-32-NEXT: RET 0, implicit [[COPY]](s16)
+ %0:_(s16) = IMPLICIT_DEF
+ %1:_(s16) = G_CONSTANT_FOLD_BARRIER %0
+ %2:_(s16) = COPY %1(s16)
+ RET 0, implicit %2
+
+...
+---
+name: test_fold8
+body: |
+ bb.0:
+ ; X86-32-LABEL: name: test_fold8
+ ; X86-32: [[DEF:%[0-9]+]]:_(s8) = IMPLICIT_DEF
+ ; X86-32-NEXT: [[CONSTANT_FOLD_BARRIER:%[0-9]+]]:_(s8) = G_CONSTANT_FOLD_BARRIER [[DEF]]
+ ; X86-32-NEXT: [[COPY:%[0-9]+]]:_(s8) = COPY [[CONSTANT_FOLD_BARRIER]](s8)
+ ; X86-32-NEXT: RET 0, implicit [[COPY]](s8)
+ %0:_(s8) = IMPLICIT_DEF
+ %1:_(s8) = G_CONSTANT_FOLD_BARRIER %0
+ %2:_(s8) = COPY %1(s8)
+ RET 0, implicit %2
+
+...
Index: llvm/lib/Target/X86/X86LegalizerInfo.cpp
===================================================================
--- llvm/lib/Target/X86/X86LegalizerInfo.cpp
+++ llvm/lib/Target/X86/X86LegalizerInfo.cpp
@@ -525,7 +525,7 @@
.minScalar(0, LLT::scalar(32))
.libcall();
- getActionDefinitionsBuilder(G_FREEZE)
+ getActionDefinitionsBuilder({G_FREEZE, G_CONSTANT_FOLD_BARRIER})
.legalFor({s8, s16, s32, s64, p0})
.widenScalarToNextPow2(0, /*Min=*/8)
.clampScalar(0, s8, sMaxScalar);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D153684.534160.patch
Type: text/x-patch
Size: 3050 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230624/0ccd0be9/attachment.bin>
More information about the llvm-commits
mailing list