[llvm] e64feaf - [M68k][GlobalISel] Legalize more instruction in M68k Legalizer.
Min-Yih Hsu via llvm-commits
llvm-commits at lists.llvm.org
Fri Jan 28 18:01:50 PST 2022
Author: Sheng
Date: 2022-01-29T09:59:58+08:00
New Revision: e64feaf00fd3b42c5820da556e60dd575f98cbe5
URL: https://github.com/llvm/llvm-project/commit/e64feaf00fd3b42c5820da556e60dd575f98cbe5
DIFF: https://github.com/llvm/llvm-project/commit/e64feaf00fd3b42c5820da556e60dd575f98cbe5.diff
LOG: [M68k][GlobalISel] Legalize more instruction in M68k Legalizer.
This patch legalizes more instructions and data types.
Differential Revision: https://reviews.llvm.org/D117264
Added:
llvm/test/CodeGen/M68k/GlobalISel/legalize-add.mir
llvm/test/CodeGen/M68k/GlobalISel/legalize-and.mir
llvm/test/CodeGen/M68k/GlobalISel/legalize-load-store.mir
llvm/test/CodeGen/M68k/GlobalISel/legalize-mul.mir
llvm/test/CodeGen/M68k/GlobalISel/legalize-sub.mir
llvm/test/CodeGen/M68k/GlobalISel/legalize-udiv.mir
Modified:
llvm/lib/Target/M68k/GISel/M68kLegalizerInfo.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Target/M68k/GISel/M68kLegalizerInfo.cpp b/llvm/lib/Target/M68k/GISel/M68kLegalizerInfo.cpp
index 860c0ce293267..79e9ad4dd1d2a 100644
--- a/llvm/lib/Target/M68k/GISel/M68kLegalizerInfo.cpp
+++ b/llvm/lib/Target/M68k/GISel/M68kLegalizerInfo.cpp
@@ -21,13 +21,32 @@ using namespace llvm;
M68kLegalizerInfo::M68kLegalizerInfo(const M68kSubtarget &ST) {
using namespace TargetOpcode;
- const LLT S32 = LLT::scalar(32);
- const LLT P0 = LLT::pointer(0, 32);
- getActionDefinitionsBuilder(G_LOAD).legalFor({S32});
- getActionDefinitionsBuilder(G_FRAME_INDEX).legalFor({P0});
- getActionDefinitionsBuilder(G_ADD).legalFor({S32});
- getActionDefinitionsBuilder(G_SUB).legalFor({S32});
- getActionDefinitionsBuilder(G_MUL).legalFor({S32});
- getActionDefinitionsBuilder(G_UDIV).legalFor({S32});
+ const LLT s8 = LLT::scalar(8);
+ const LLT s16 = LLT::scalar(16);
+ const LLT s32 = LLT::scalar(32);
+ const LLT p0 = LLT::pointer(0, 32);
+
+ getActionDefinitionsBuilder({G_ADD, G_SUB, G_MUL, G_UDIV, G_AND})
+ .legalFor({s8, s16, s32})
+ .clampScalar(0, s8, s32)
+ .widenScalarToNextPow2(0, 8);
+
+ getActionDefinitionsBuilder(G_CONSTANT)
+ .legalFor({s32, p0})
+ .clampScalar(0, s32, s32);
+
+ getActionDefinitionsBuilder({G_FRAME_INDEX, G_GLOBAL_VALUE}).legalFor({p0});
+
+ getActionDefinitionsBuilder({G_STORE, G_LOAD})
+ .legalForTypesWithMemDesc({{s32, p0, s32, 4},
+ {s32, p0, s16, 4},
+ {s32, p0, s8, 4},
+ {s16, p0, s16, 2},
+ {s8, p0, s8, 1},
+ {p0, p0, s32, 4}})
+ .clampScalar(0, s8, s32);
+
+ getActionDefinitionsBuilder(G_PTR_ADD).legalFor({{p0, s32}});
+
getLegacyLegalizerInfo().computeTables();
}
diff --git a/llvm/test/CodeGen/M68k/GlobalISel/legalize-add.mir b/llvm/test/CodeGen/M68k/GlobalISel/legalize-add.mir
new file mode 100644
index 0000000000000..c9df0691bb763
--- /dev/null
+++ b/llvm/test/CodeGen/M68k/GlobalISel/legalize-add.mir
@@ -0,0 +1,66 @@
+# NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
+# RUN: llc -march=m68k -run-pass=legalizer -verify-machineinstrs %s -o - | FileCheck %s
+---
+name: test_scalar_small
+fixedStack:
+ - { id: 0, type: default, offset: 4, size: 1, alignment: 4, stack-id: default,
+ isImmutable: true, isAliased: false, callee-saved-register: '', callee-saved-restored: true,
+ debug-info-variable: '', debug-info-expression: '', debug-info-location: '' }
+ - { id: 1, type: default, offset: 0, size: 1, alignment: 8, stack-id: default,
+ isImmutable: true, isAliased: false, callee-saved-register: '', callee-saved-restored: true,
+ debug-info-variable: '', debug-info-expression: '', debug-info-location: '' }
+body: |
+ bb.1:
+ ; CHECK-LABEL: name: test_scalar_small
+ ; CHECK: [[FRAME_INDEX:%[0-9]+]]:_(p0) = G_FRAME_INDEX %fixed-stack.0
+ ; CHECK-NEXT: [[LOAD:%[0-9]+]]:_(s32) = G_LOAD [[FRAME_INDEX]](p0) :: (load (s8) from %fixed-stack.0, align 8)
+ ; CHECK-NEXT: [[FRAME_INDEX1:%[0-9]+]]:_(p0) = G_FRAME_INDEX %fixed-stack.1
+ ; CHECK-NEXT: [[LOAD1:%[0-9]+]]:_(s32) = G_LOAD [[FRAME_INDEX1]](p0) :: (load (s8) from %fixed-stack.1, align 4)
+ ; CHECK-NEXT: [[TRUNC:%[0-9]+]]:_(s8) = G_TRUNC [[LOAD]](s32)
+ ; CHECK-NEXT: [[TRUNC1:%[0-9]+]]:_(s8) = G_TRUNC [[LOAD1]](s32)
+ ; CHECK-NEXT: [[ADD:%[0-9]+]]:_(s8) = G_ADD [[TRUNC]], [[TRUNC1]]
+ ; CHECK-NEXT: $bd0 = COPY [[ADD]](s8)
+ ; CHECK-NEXT: RTS implicit $bd0
+ %3:_(p0) = G_FRAME_INDEX %fixed-stack.1
+ %2:_(s32) = G_LOAD %3(p0) :: (load (s8) from %fixed-stack.1, align 8)
+ %0:_(s1) = G_TRUNC %2(s32)
+ %5:_(p0) = G_FRAME_INDEX %fixed-stack.0
+ %4:_(s32) = G_LOAD %5(p0) :: (load (s8) from %fixed-stack.0, align 4)
+ %1:_(s1) = G_TRUNC %4(s32)
+ %6:_(s1) = G_ADD %0, %1
+ %7:_(s8) = G_ANYEXT %6(s1)
+ $bd0 = COPY %7(s8)
+ RTS implicit $bd0
+
+...
+---
+name: test_scalar_nonpow2
+fixedStack:
+ - { id: 0, type: default, offset: 4, size: 4, alignment: 4, stack-id: default,
+ isImmutable: true, isAliased: false, callee-saved-register: '', callee-saved-restored: true,
+ debug-info-variable: '', debug-info-expression: '', debug-info-location: '' }
+ - { id: 1, type: default, offset: 0, size: 4, alignment: 8, stack-id: default,
+ isImmutable: true, isAliased: false, callee-saved-register: '', callee-saved-restored: true,
+ debug-info-variable: '', debug-info-expression: '', debug-info-location: '' }
+body: |
+ bb.1:
+ ; CHECK-LABEL: name: test_scalar_nonpow2
+ ; CHECK: [[FRAME_INDEX:%[0-9]+]]:_(p0) = G_FRAME_INDEX %fixed-stack.0
+ ; CHECK-NEXT: [[LOAD:%[0-9]+]]:_(s32) = G_LOAD [[FRAME_INDEX]](p0) :: (load (s32) from %fixed-stack.0, align 8)
+ ; CHECK-NEXT: [[FRAME_INDEX1:%[0-9]+]]:_(p0) = G_FRAME_INDEX %fixed-stack.1
+ ; CHECK-NEXT: [[LOAD1:%[0-9]+]]:_(s32) = G_LOAD [[FRAME_INDEX1]](p0) :: (load (s32) from %fixed-stack.1)
+ ; CHECK-NEXT: [[ADD:%[0-9]+]]:_(s32) = G_ADD [[LOAD]], [[LOAD1]]
+ ; CHECK-NEXT: $d0 = COPY [[ADD]](s32)
+ ; CHECK-NEXT: RTS implicit $d0
+ %3:_(p0) = G_FRAME_INDEX %fixed-stack.1
+ %2:_(s32) = G_LOAD %3(p0) :: (load (s32) from %fixed-stack.1, align 8)
+ %0:_(s17) = G_TRUNC %2(s32)
+ %5:_(p0) = G_FRAME_INDEX %fixed-stack.0
+ %4:_(s32) = G_LOAD %5(p0) :: (load (s32) from %fixed-stack.0)
+ %1:_(s17) = G_TRUNC %4(s32)
+ %6:_(s17) = G_ADD %0, %1
+ %7:_(s32) = G_ANYEXT %6(s17)
+ $d0 = COPY %7(s32)
+ RTS implicit $d0
+
+...
diff --git a/llvm/test/CodeGen/M68k/GlobalISel/legalize-and.mir b/llvm/test/CodeGen/M68k/GlobalISel/legalize-and.mir
new file mode 100644
index 0000000000000..7cd575e518d99
--- /dev/null
+++ b/llvm/test/CodeGen/M68k/GlobalISel/legalize-and.mir
@@ -0,0 +1,67 @@
+# NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
+# RUN: llc -march=m68k -run-pass=legalizer -verify-machineinstrs %s -o - | FileCheck %s
+
+---
+name: test_scalar_and_small
+fixedStack:
+ - { id: 0, type: default, offset: 4, size: 1, alignment: 4, stack-id: default,
+ isImmutable: true, isAliased: false, callee-saved-register: '', callee-saved-restored: true,
+ debug-info-variable: '', debug-info-expression: '', debug-info-location: '' }
+ - { id: 1, type: default, offset: 0, size: 1, alignment: 8, stack-id: default,
+ isImmutable: true, isAliased: false, callee-saved-register: '', callee-saved-restored: true,
+ debug-info-variable: '', debug-info-expression: '', debug-info-location: '' }
+body: |
+ bb.1:
+ ; CHECK-LABEL: name: test_scalar_and_small
+ ; CHECK: [[FRAME_INDEX:%[0-9]+]]:_(p0) = G_FRAME_INDEX %fixed-stack.0
+ ; CHECK-NEXT: [[LOAD:%[0-9]+]]:_(s32) = G_LOAD [[FRAME_INDEX]](p0) :: (load (s8) from %fixed-stack.0, align 8)
+ ; CHECK-NEXT: [[FRAME_INDEX1:%[0-9]+]]:_(p0) = G_FRAME_INDEX %fixed-stack.1
+ ; CHECK-NEXT: [[LOAD1:%[0-9]+]]:_(s32) = G_LOAD [[FRAME_INDEX1]](p0) :: (load (s8) from %fixed-stack.1, align 4)
+ ; CHECK-NEXT: [[TRUNC:%[0-9]+]]:_(s8) = G_TRUNC [[LOAD]](s32)
+ ; CHECK-NEXT: [[TRUNC1:%[0-9]+]]:_(s8) = G_TRUNC [[LOAD1]](s32)
+ ; CHECK-NEXT: [[AND:%[0-9]+]]:_(s8) = G_AND [[TRUNC]], [[TRUNC1]]
+ ; CHECK-NEXT: $bd0 = COPY [[AND]](s8)
+ ; CHECK-NEXT: RTS implicit $bd0
+ %3:_(p0) = G_FRAME_INDEX %fixed-stack.1
+ %2:_(s32) = G_LOAD %3(p0) :: (load (s8) from %fixed-stack.1, align 8)
+ %0:_(s2) = G_TRUNC %2(s32)
+ %5:_(p0) = G_FRAME_INDEX %fixed-stack.0
+ %4:_(s32) = G_LOAD %5(p0) :: (load (s8) from %fixed-stack.0, align 4)
+ %1:_(s2) = G_TRUNC %4(s32)
+ %6:_(s2) = G_AND %0, %1
+ %7:_(s8) = G_ANYEXT %6(s2)
+ $bd0 = COPY %7(s8)
+ RTS implicit $bd0
+
+...
+---
+name: test_scalar_nonpow2
+fixedStack:
+ - { id: 0, type: default, offset: 4, size: 4, alignment: 4, stack-id: default,
+ isImmutable: true, isAliased: false, callee-saved-register: '', callee-saved-restored: true,
+ debug-info-variable: '', debug-info-expression: '', debug-info-location: '' }
+ - { id: 1, type: default, offset: 0, size: 4, alignment: 8, stack-id: default,
+ isImmutable: true, isAliased: false, callee-saved-register: '', callee-saved-restored: true,
+ debug-info-variable: '', debug-info-expression: '', debug-info-location: '' }
+body: |
+ bb.1:
+ ; CHECK-LABEL: name: test_scalar_nonpow2
+ ; CHECK: [[FRAME_INDEX:%[0-9]+]]:_(p0) = G_FRAME_INDEX %fixed-stack.0
+ ; CHECK-NEXT: [[LOAD:%[0-9]+]]:_(s32) = G_LOAD [[FRAME_INDEX]](p0) :: (load (s32) from %fixed-stack.0, align 8)
+ ; CHECK-NEXT: [[FRAME_INDEX1:%[0-9]+]]:_(p0) = G_FRAME_INDEX %fixed-stack.1
+ ; CHECK-NEXT: [[LOAD1:%[0-9]+]]:_(s32) = G_LOAD [[FRAME_INDEX1]](p0) :: (load (s32) from %fixed-stack.1)
+ ; CHECK-NEXT: [[AND:%[0-9]+]]:_(s32) = G_AND [[LOAD]], [[LOAD1]]
+ ; CHECK-NEXT: $d0 = COPY [[AND]](s32)
+ ; CHECK-NEXT: RTS implicit $d0
+ %3:_(p0) = G_FRAME_INDEX %fixed-stack.1
+ %2:_(s32) = G_LOAD %3(p0) :: (load (s32) from %fixed-stack.1, align 8)
+ %0:_(s17) = G_TRUNC %2(s32)
+ %5:_(p0) = G_FRAME_INDEX %fixed-stack.0
+ %4:_(s32) = G_LOAD %5(p0) :: (load (s32) from %fixed-stack.0)
+ %1:_(s17) = G_TRUNC %4(s32)
+ %6:_(s17) = G_AND %0, %1
+ %7:_(s32) = G_ANYEXT %6(s17)
+ $d0 = COPY %7(s32)
+ RTS implicit $d0
+
+...
diff --git a/llvm/test/CodeGen/M68k/GlobalISel/legalize-load-store.mir b/llvm/test/CodeGen/M68k/GlobalISel/legalize-load-store.mir
new file mode 100644
index 0000000000000..5328ef71c310e
--- /dev/null
+++ b/llvm/test/CodeGen/M68k/GlobalISel/legalize-load-store.mir
@@ -0,0 +1,66 @@
+# NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
+# RUN: llc -march=m68k -run-pass=legalizer -verify-machineinstrs %s -o - | FileCheck %s
+
+---
+name: test_load_store
+fixedStack:
+ - { id: 0, type: default, offset: 20, size: 4, alignment: 4, stack-id: default,
+ isImmutable: true, isAliased: false, callee-saved-register: '', callee-saved-restored: true,
+ debug-info-variable: '', debug-info-expression: '', debug-info-location: '' }
+ - { id: 1, type: default, offset: 16, size: 4, alignment: 8, stack-id: default,
+ isImmutable: true, isAliased: false, callee-saved-register: '', callee-saved-restored: true,
+ debug-info-variable: '', debug-info-expression: '', debug-info-location: '' }
+ - { id: 2, type: default, offset: 12, size: 4, alignment: 4, stack-id: default,
+ isImmutable: true, isAliased: false, callee-saved-register: '', callee-saved-restored: true,
+ debug-info-variable: '', debug-info-expression: '', debug-info-location: '' }
+ - { id: 3, type: default, offset: 8, size: 2, alignment: 8, stack-id: default,
+ isImmutable: true, isAliased: false, callee-saved-register: '', callee-saved-restored: true,
+ debug-info-variable: '', debug-info-expression: '', debug-info-location: '' }
+ - { id: 4, type: default, offset: 4, size: 4, alignment: 4, stack-id: default,
+ isImmutable: true, isAliased: false, callee-saved-register: '', callee-saved-restored: true,
+ debug-info-variable: '', debug-info-expression: '', debug-info-location: '' }
+ - { id: 5, type: default, offset: 0, size: 1, alignment: 8, stack-id: default,
+ isImmutable: true, isAliased: false, callee-saved-register: '', callee-saved-restored: true,
+ debug-info-variable: '', debug-info-expression: '', debug-info-location: '' }
+body: |
+ bb.1 :
+ ; CHECK-LABEL: name: test_load_store
+ ; CHECK: [[FRAME_INDEX:%[0-9]+]]:_(p0) = G_FRAME_INDEX %fixed-stack.0
+ ; CHECK-NEXT: [[LOAD:%[0-9]+]]:_(s32) = G_LOAD [[FRAME_INDEX]](p0) :: (load (s8) from %fixed-stack.0, align 8)
+ ; CHECK-NEXT: [[TRUNC:%[0-9]+]]:_(s8) = G_TRUNC [[LOAD]](s32)
+ ; CHECK-NEXT: [[FRAME_INDEX1:%[0-9]+]]:_(p0) = G_FRAME_INDEX %fixed-stack.1
+ ; CHECK-NEXT: [[LOAD1:%[0-9]+]]:_(p0) = G_LOAD [[FRAME_INDEX1]](p0) :: (load (p0) from %fixed-stack.1)
+ ; CHECK-NEXT: [[FRAME_INDEX2:%[0-9]+]]:_(p0) = G_FRAME_INDEX %fixed-stack.2
+ ; CHECK-NEXT: [[LOAD2:%[0-9]+]]:_(s32) = G_LOAD [[FRAME_INDEX2]](p0) :: (load (s16) from %fixed-stack.2, align 8)
+ ; CHECK-NEXT: [[TRUNC1:%[0-9]+]]:_(s16) = G_TRUNC [[LOAD2]](s32)
+ ; CHECK-NEXT: [[FRAME_INDEX3:%[0-9]+]]:_(p0) = G_FRAME_INDEX %fixed-stack.3
+ ; CHECK-NEXT: [[LOAD3:%[0-9]+]]:_(p0) = G_LOAD [[FRAME_INDEX3]](p0) :: (load (p0) from %fixed-stack.3)
+ ; CHECK-NEXT: [[FRAME_INDEX4:%[0-9]+]]:_(p0) = G_FRAME_INDEX %fixed-stack.4
+ ; CHECK-NEXT: [[LOAD4:%[0-9]+]]:_(s32) = G_LOAD [[FRAME_INDEX4]](p0) :: (load (s32) from %fixed-stack.4, align 8)
+ ; CHECK-NEXT: [[FRAME_INDEX5:%[0-9]+]]:_(p0) = G_FRAME_INDEX %fixed-stack.5
+ ; CHECK-NEXT: [[LOAD5:%[0-9]+]]:_(p0) = G_LOAD [[FRAME_INDEX5]](p0) :: (load (p0) from %fixed-stack.5)
+ ; CHECK-NEXT: G_STORE [[TRUNC]](s8), [[LOAD1]](p0) :: (store (s8))
+ ; CHECK-NEXT: G_STORE [[TRUNC1]](s16), [[LOAD3]](p0) :: (store (s16))
+ ; CHECK-NEXT: G_STORE [[LOAD4]](s32), [[LOAD5]](p0) :: (store (s32))
+ ; CHECK-NEXT: RTS
+ %7:_(p0) = G_FRAME_INDEX %fixed-stack.5
+ %6:_(s32) = G_LOAD %7(p0) :: (load (s8) from %fixed-stack.5, align 8)
+ %0:_(s8) = G_TRUNC %6(s32)
+ %8:_(p0) = G_FRAME_INDEX %fixed-stack.4
+ %1:_(p0) = G_LOAD %8(p0) :: (load (p0) from %fixed-stack.4)
+ %10:_(p0) = G_FRAME_INDEX %fixed-stack.3
+ %9:_(s32) = G_LOAD %10(p0) :: (load (s16) from %fixed-stack.3, align 8)
+ %2:_(s16) = G_TRUNC %9(s32)
+ %11:_(p0) = G_FRAME_INDEX %fixed-stack.2
+ %3:_(p0) = G_LOAD %11(p0) :: (load (p0) from %fixed-stack.2)
+ %12:_(p0) = G_FRAME_INDEX %fixed-stack.1
+ %4:_(s32) = G_LOAD %12(p0) :: (load (s32) from %fixed-stack.1, align 8)
+ %13:_(p0) = G_FRAME_INDEX %fixed-stack.0
+ %5:_(p0) = G_LOAD %13(p0) :: (load (p0) from %fixed-stack.0)
+ G_STORE %0(s8), %1(p0) :: (store (s8))
+ G_STORE %2(s16), %3(p0) :: (store (s16))
+ G_STORE %4(s32), %5(p0) :: (store (s32))
+ RTS
+
+...
+
diff --git a/llvm/test/CodeGen/M68k/GlobalISel/legalize-mul.mir b/llvm/test/CodeGen/M68k/GlobalISel/legalize-mul.mir
new file mode 100644
index 0000000000000..424bee6b71afb
--- /dev/null
+++ b/llvm/test/CodeGen/M68k/GlobalISel/legalize-mul.mir
@@ -0,0 +1,67 @@
+# NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
+# RUN: llc -march=m68k -run-pass=legalizer -verify-machineinstrs %s -o - | FileCheck %s
+
+---
+name: test_scalar_small
+fixedStack:
+ - { id: 0, type: default, offset: 4, size: 1, alignment: 4, stack-id: default,
+ isImmutable: true, isAliased: false, callee-saved-register: '', callee-saved-restored: true,
+ debug-info-variable: '', debug-info-expression: '', debug-info-location: '' }
+ - { id: 1, type: default, offset: 0, size: 1, alignment: 8, stack-id: default,
+ isImmutable: true, isAliased: false, callee-saved-register: '', callee-saved-restored: true,
+ debug-info-variable: '', debug-info-expression: '', debug-info-location: '' }
+body: |
+ bb.1:
+ ; CHECK-LABEL: name: test_scalar_small
+ ; CHECK: [[FRAME_INDEX:%[0-9]+]]:_(p0) = G_FRAME_INDEX %fixed-stack.0
+ ; CHECK-NEXT: [[LOAD:%[0-9]+]]:_(s32) = G_LOAD [[FRAME_INDEX]](p0) :: (load (s8) from %fixed-stack.0, align 8)
+ ; CHECK-NEXT: [[FRAME_INDEX1:%[0-9]+]]:_(p0) = G_FRAME_INDEX %fixed-stack.1
+ ; CHECK-NEXT: [[LOAD1:%[0-9]+]]:_(s32) = G_LOAD [[FRAME_INDEX1]](p0) :: (load (s8) from %fixed-stack.1, align 4)
+ ; CHECK-NEXT: [[TRUNC:%[0-9]+]]:_(s8) = G_TRUNC [[LOAD]](s32)
+ ; CHECK-NEXT: [[TRUNC1:%[0-9]+]]:_(s8) = G_TRUNC [[LOAD1]](s32)
+ ; CHECK-NEXT: [[MUL:%[0-9]+]]:_(s8) = G_MUL [[TRUNC]], [[TRUNC1]]
+ ; CHECK-NEXT: $bd0 = COPY [[MUL]](s8)
+ ; CHECK-NEXT: RTS implicit $bd0
+ %3:_(p0) = G_FRAME_INDEX %fixed-stack.1
+ %2:_(s32) = G_LOAD %3(p0) :: (load (s8) from %fixed-stack.1, align 8)
+ %0:_(s2) = G_TRUNC %2(s32)
+ %5:_(p0) = G_FRAME_INDEX %fixed-stack.0
+ %4:_(s32) = G_LOAD %5(p0) :: (load (s8) from %fixed-stack.0, align 4)
+ %1:_(s2) = G_TRUNC %4(s32)
+ %6:_(s2) = G_MUL %0, %1
+ %7:_(s8) = G_ANYEXT %6(s2)
+ $bd0 = COPY %7(s8)
+ RTS implicit $bd0
+
+...
+---
+name: test_scalar_nonpow2
+fixedStack:
+ - { id: 0, type: default, offset: 4, size: 4, alignment: 4, stack-id: default,
+ isImmutable: true, isAliased: false, callee-saved-register: '', callee-saved-restored: true,
+ debug-info-variable: '', debug-info-expression: '', debug-info-location: '' }
+ - { id: 1, type: default, offset: 0, size: 4, alignment: 8, stack-id: default,
+ isImmutable: true, isAliased: false, callee-saved-register: '', callee-saved-restored: true,
+ debug-info-variable: '', debug-info-expression: '', debug-info-location: '' }
+body: |
+ bb.1:
+ ; CHECK-LABEL: name: test_scalar_nonpow2
+ ; CHECK: [[FRAME_INDEX:%[0-9]+]]:_(p0) = G_FRAME_INDEX %fixed-stack.0
+ ; CHECK-NEXT: [[LOAD:%[0-9]+]]:_(s32) = G_LOAD [[FRAME_INDEX]](p0) :: (load (s32) from %fixed-stack.0, align 8)
+ ; CHECK-NEXT: [[FRAME_INDEX1:%[0-9]+]]:_(p0) = G_FRAME_INDEX %fixed-stack.1
+ ; CHECK-NEXT: [[LOAD1:%[0-9]+]]:_(s32) = G_LOAD [[FRAME_INDEX1]](p0) :: (load (s32) from %fixed-stack.1)
+ ; CHECK-NEXT: [[MUL:%[0-9]+]]:_(s32) = G_MUL [[LOAD]], [[LOAD1]]
+ ; CHECK-NEXT: $d0 = COPY [[MUL]](s32)
+ ; CHECK-NEXT: RTS implicit $d0
+ %3:_(p0) = G_FRAME_INDEX %fixed-stack.1
+ %2:_(s32) = G_LOAD %3(p0) :: (load (s32) from %fixed-stack.1, align 8)
+ %0:_(s17) = G_TRUNC %2(s32)
+ %5:_(p0) = G_FRAME_INDEX %fixed-stack.0
+ %4:_(s32) = G_LOAD %5(p0) :: (load (s32) from %fixed-stack.0)
+ %1:_(s17) = G_TRUNC %4(s32)
+ %6:_(s17) = G_MUL %0, %1
+ %7:_(s32) = G_ANYEXT %6(s17)
+ $d0 = COPY %7(s32)
+ RTS implicit $d0
+
+...
diff --git a/llvm/test/CodeGen/M68k/GlobalISel/legalize-sub.mir b/llvm/test/CodeGen/M68k/GlobalISel/legalize-sub.mir
new file mode 100644
index 0000000000000..2af0e097d4d4f
--- /dev/null
+++ b/llvm/test/CodeGen/M68k/GlobalISel/legalize-sub.mir
@@ -0,0 +1,68 @@
+# NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
+# RUN: llc -march=m68k -run-pass=legalizer -verify-machineinstrs %s -o - | FileCheck %s
+
+---
+name: test_scalar_small
+fixedStack:
+ - { id: 0, type: default, offset: 4, size: 1, alignment: 4, stack-id: default,
+ isImmutable: true, isAliased: false, callee-saved-register: '', callee-saved-restored: true,
+ debug-info-variable: '', debug-info-expression: '', debug-info-location: '' }
+ - { id: 1, type: default, offset: 0, size: 1, alignment: 8, stack-id: default,
+ isImmutable: true, isAliased: false, callee-saved-register: '', callee-saved-restored: true,
+ debug-info-variable: '', debug-info-expression: '', debug-info-location: '' }
+
+body: |
+ bb.1:
+ ; CHECK-LABEL: name: test_scalar_small
+ ; CHECK: [[FRAME_INDEX:%[0-9]+]]:_(p0) = G_FRAME_INDEX %fixed-stack.0
+ ; CHECK-NEXT: [[LOAD:%[0-9]+]]:_(s32) = G_LOAD [[FRAME_INDEX]](p0) :: (load (s8) from %fixed-stack.0, align 8)
+ ; CHECK-NEXT: [[FRAME_INDEX1:%[0-9]+]]:_(p0) = G_FRAME_INDEX %fixed-stack.1
+ ; CHECK-NEXT: [[LOAD1:%[0-9]+]]:_(s32) = G_LOAD [[FRAME_INDEX1]](p0) :: (load (s8) from %fixed-stack.1, align 4)
+ ; CHECK-NEXT: [[TRUNC:%[0-9]+]]:_(s8) = G_TRUNC [[LOAD]](s32)
+ ; CHECK-NEXT: [[TRUNC1:%[0-9]+]]:_(s8) = G_TRUNC [[LOAD1]](s32)
+ ; CHECK-NEXT: [[SUB:%[0-9]+]]:_(s8) = G_SUB [[TRUNC]], [[TRUNC1]]
+ ; CHECK-NEXT: $bd0 = COPY [[SUB]](s8)
+ ; CHECK-NEXT: RTS implicit $bd0
+ %3:_(p0) = G_FRAME_INDEX %fixed-stack.1
+ %2:_(s32) = G_LOAD %3(p0) :: (load (s8) from %fixed-stack.1, align 8)
+ %0:_(s2) = G_TRUNC %2(s32)
+ %5:_(p0) = G_FRAME_INDEX %fixed-stack.0
+ %4:_(s32) = G_LOAD %5(p0) :: (load (s8) from %fixed-stack.0, align 4)
+ %1:_(s2) = G_TRUNC %4(s32)
+ %6:_(s2) = G_SUB %0, %1
+ %7:_(s8) = G_ANYEXT %6(s2)
+ $bd0 = COPY %7(s8)
+ RTS implicit $bd0
+
+...
+---
+name: test_scalar_nonpow2
+fixedStack:
+ - { id: 0, type: default, offset: 4, size: 4, alignment: 4, stack-id: default,
+ isImmutable: true, isAliased: false, callee-saved-register: '', callee-saved-restored: true,
+ debug-info-variable: '', debug-info-expression: '', debug-info-location: '' }
+ - { id: 1, type: default, offset: 0, size: 4, alignment: 8, stack-id: default,
+ isImmutable: true, isAliased: false, callee-saved-register: '', callee-saved-restored: true,
+ debug-info-variable: '', debug-info-expression: '', debug-info-location: '' }
+body: |
+ bb.1:
+ ; CHECK-LABEL: name: test_scalar_nonpow2
+ ; CHECK: [[FRAME_INDEX:%[0-9]+]]:_(p0) = G_FRAME_INDEX %fixed-stack.0
+ ; CHECK-NEXT: [[LOAD:%[0-9]+]]:_(s32) = G_LOAD [[FRAME_INDEX]](p0) :: (load (s32) from %fixed-stack.0, align 8)
+ ; CHECK-NEXT: [[FRAME_INDEX1:%[0-9]+]]:_(p0) = G_FRAME_INDEX %fixed-stack.1
+ ; CHECK-NEXT: [[LOAD1:%[0-9]+]]:_(s32) = G_LOAD [[FRAME_INDEX1]](p0) :: (load (s32) from %fixed-stack.1)
+ ; CHECK-NEXT: [[SUB:%[0-9]+]]:_(s32) = G_SUB [[LOAD]], [[LOAD1]]
+ ; CHECK-NEXT: $d0 = COPY [[SUB]](s32)
+ ; CHECK-NEXT: RTS implicit $d0
+ %3:_(p0) = G_FRAME_INDEX %fixed-stack.1
+ %2:_(s32) = G_LOAD %3(p0) :: (load (s32) from %fixed-stack.1, align 8)
+ %0:_(s17) = G_TRUNC %2(s32)
+ %5:_(p0) = G_FRAME_INDEX %fixed-stack.0
+ %4:_(s32) = G_LOAD %5(p0) :: (load (s32) from %fixed-stack.0)
+ %1:_(s17) = G_TRUNC %4(s32)
+ %6:_(s17) = G_SUB %0, %1
+ %7:_(s32) = G_ANYEXT %6(s17)
+ $d0 = COPY %7(s32)
+ RTS implicit $d0
+
+...
diff --git a/llvm/test/CodeGen/M68k/GlobalISel/legalize-udiv.mir b/llvm/test/CodeGen/M68k/GlobalISel/legalize-udiv.mir
new file mode 100644
index 0000000000000..439a961113908
--- /dev/null
+++ b/llvm/test/CodeGen/M68k/GlobalISel/legalize-udiv.mir
@@ -0,0 +1,76 @@
+# NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
+# RUN: llc -march=m68k -run-pass=legalizer -verify-machineinstrs %s -o - | FileCheck %s
+---
+name: test_scalar_small
+fixedStack:
+ - { id: 0, type: default, offset: 4, size: 1, alignment: 4, stack-id: default,
+ isImmutable: true, isAliased: false, callee-saved-register: '', callee-saved-restored: true,
+ debug-info-variable: '', debug-info-expression: '', debug-info-location: '' }
+ - { id: 1, type: default, offset: 0, size: 1, alignment: 8, stack-id: default,
+ isImmutable: true, isAliased: false, callee-saved-register: '', callee-saved-restored: true,
+ debug-info-variable: '', debug-info-expression: '', debug-info-location: '' }
+body: |
+ bb.1:
+ ; CHECK-LABEL: name: test_scalar_small
+ ; CHECK: [[FRAME_INDEX:%[0-9]+]]:_(p0) = G_FRAME_INDEX %fixed-stack.0
+ ; CHECK-NEXT: [[LOAD:%[0-9]+]]:_(s32) = G_LOAD [[FRAME_INDEX]](p0) :: (load (s8) from %fixed-stack.0, align 8)
+ ; CHECK-NEXT: [[FRAME_INDEX1:%[0-9]+]]:_(p0) = G_FRAME_INDEX %fixed-stack.1
+ ; CHECK-NEXT: [[LOAD1:%[0-9]+]]:_(s32) = G_LOAD [[FRAME_INDEX1]](p0) :: (load (s8) from %fixed-stack.1, align 4)
+ ; CHECK-NEXT: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 3
+ ; CHECK-NEXT: [[TRUNC:%[0-9]+]]:_(s8) = G_TRUNC [[C]](s32)
+ ; CHECK-NEXT: [[TRUNC1:%[0-9]+]]:_(s8) = G_TRUNC [[LOAD]](s32)
+ ; CHECK-NEXT: [[AND:%[0-9]+]]:_(s8) = G_AND [[TRUNC1]], [[TRUNC]]
+ ; CHECK-NEXT: [[C1:%[0-9]+]]:_(s32) = G_CONSTANT i32 3
+ ; CHECK-NEXT: [[TRUNC2:%[0-9]+]]:_(s8) = G_TRUNC [[C1]](s32)
+ ; CHECK-NEXT: [[TRUNC3:%[0-9]+]]:_(s8) = G_TRUNC [[LOAD1]](s32)
+ ; CHECK-NEXT: [[AND1:%[0-9]+]]:_(s8) = G_AND [[TRUNC3]], [[TRUNC2]]
+ ; CHECK-NEXT: [[UDIV:%[0-9]+]]:_(s8) = G_UDIV [[AND]], [[AND1]]
+ ; CHECK-NEXT: $bd0 = COPY [[UDIV]](s8)
+ ; CHECK-NEXT: RTS implicit $bd0
+ %3:_(p0) = G_FRAME_INDEX %fixed-stack.1
+ %2:_(s32) = G_LOAD %3(p0) :: (load (s8) from %fixed-stack.1, align 8)
+ %0:_(s2) = G_TRUNC %2(s32)
+ %5:_(p0) = G_FRAME_INDEX %fixed-stack.0
+ %4:_(s32) = G_LOAD %5(p0) :: (load (s8) from %fixed-stack.0, align 4)
+ %1:_(s2) = G_TRUNC %4(s32)
+ %6:_(s2) = G_UDIV %0, %1
+ %7:_(s8) = G_ANYEXT %6(s2)
+ $bd0 = COPY %7(s8)
+ RTS implicit $bd0
+
+...
+---
+name: test_scalar_nonpow2
+fixedStack:
+ - { id: 0, type: default, offset: 4, size: 4, alignment: 4, stack-id: default,
+ isImmutable: true, isAliased: false, callee-saved-register: '', callee-saved-restored: true,
+ debug-info-variable: '', debug-info-expression: '', debug-info-location: '' }
+ - { id: 1, type: default, offset: 0, size: 4, alignment: 8, stack-id: default,
+ isImmutable: true, isAliased: false, callee-saved-register: '', callee-saved-restored: true,
+ debug-info-variable: '', debug-info-expression: '', debug-info-location: '' }
+body: |
+ bb.1:
+ ; CHECK-LABEL: name: test_scalar_nonpow2
+ ; CHECK: [[FRAME_INDEX:%[0-9]+]]:_(p0) = G_FRAME_INDEX %fixed-stack.0
+ ; CHECK-NEXT: [[LOAD:%[0-9]+]]:_(s32) = G_LOAD [[FRAME_INDEX]](p0) :: (load (s32) from %fixed-stack.0, align 8)
+ ; CHECK-NEXT: [[FRAME_INDEX1:%[0-9]+]]:_(p0) = G_FRAME_INDEX %fixed-stack.1
+ ; CHECK-NEXT: [[LOAD1:%[0-9]+]]:_(s32) = G_LOAD [[FRAME_INDEX1]](p0) :: (load (s32) from %fixed-stack.1)
+ ; CHECK-NEXT: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 131071
+ ; CHECK-NEXT: [[AND:%[0-9]+]]:_(s32) = G_AND [[LOAD]], [[C]]
+ ; CHECK-NEXT: [[C1:%[0-9]+]]:_(s32) = G_CONSTANT i32 131071
+ ; CHECK-NEXT: [[AND1:%[0-9]+]]:_(s32) = G_AND [[LOAD1]], [[C1]]
+ ; CHECK-NEXT: [[UDIV:%[0-9]+]]:_(s32) = G_UDIV [[AND]], [[AND1]]
+ ; CHECK-NEXT: $d0 = COPY [[UDIV]](s32)
+ ; CHECK-NEXT: RTS implicit $d0
+ %3:_(p0) = G_FRAME_INDEX %fixed-stack.1
+ %2:_(s32) = G_LOAD %3(p0) :: (load (s32) from %fixed-stack.1, align 8)
+ %0:_(s17) = G_TRUNC %2(s32)
+ %5:_(p0) = G_FRAME_INDEX %fixed-stack.0
+ %4:_(s32) = G_LOAD %5(p0) :: (load (s32) from %fixed-stack.0)
+ %1:_(s17) = G_TRUNC %4(s32)
+ %6:_(s17) = G_UDIV %0, %1
+ %7:_(s32) = G_ANYEXT %6(s17)
+ $d0 = COPY %7(s32)
+ RTS implicit $d0
+
+...
More information about the llvm-commits
mailing list