llvm/llvm/test/CodeGen/M68k/GlobalISel/legalize-udiv.mir

# 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: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 3
    ; CHECK-NEXT: [[TRUNC1:%[0-9]+]]:_(s8) = G_TRUNC [[C]](s32)
    ; CHECK-NEXT: [[AND:%[0-9]+]]:_(s8) = G_AND [[TRUNC]], [[TRUNC1]]
    ; CHECK-NEXT: [[TRUNC2:%[0-9]+]]:_(s8) = G_TRUNC [[LOAD1]](s32)
    ; CHECK-NEXT: [[C1:%[0-9]+]]:_(s32) = G_CONSTANT i32 3
    ; CHECK-NEXT: [[TRUNC3:%[0-9]+]]:_(s8) = G_TRUNC [[C1]](s32)
    ; CHECK-NEXT: [[AND1:%[0-9]+]]:_(s8) = G_AND [[TRUNC2]], [[TRUNC3]]
    ; 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

...