llvm/llvm/test/CodeGen/X86/GlobalISel/legalize-or-scalar.mir

# NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
# RUN: llc -O0 -mtriple=x86_64-linux-gnu -run-pass=legalizer %s -o - | FileCheck %s --check-prefixes=CHECK,X64
# RUN: llc -O0 -mtriple=i386-linux-gnu -run-pass=legalizer %s -o - | FileCheck %s --check-prefixes=CHECK,X86

--- |

  define void @test_or_i1() { ret void}
  define void @test_or_i8() { ret void }
  define void @test_or_i16() { ret void }
  define void @test_or_i27() { ret void }
  define void @test_or_i32() { ret void }
  define void @test_or_i42() { ret void }
  define void @test_or_i64() { ret void }

...
---
name:            test_or_i1
alignment:       16
legalized:       false
regBankSelected: false
registers:
  - { id: 0, class: _, preferred-register: '' }
  - { id: 1, class: _, preferred-register: '' }
  - { id: 2, class: _, preferred-register: '' }
body:             |
  bb.1 (%ir-block.0):
    ; CHECK-LABEL: name: test_or_i1
    ; CHECK: [[COPY:%[0-9]+]]:_(s32) = COPY $edx
    ; CHECK-NEXT: [[TRUNC:%[0-9]+]]:_(s8) = G_TRUNC [[COPY]](s32)
    ; CHECK-NEXT: [[TRUNC1:%[0-9]+]]:_(s8) = G_TRUNC [[COPY]](s32)
    ; CHECK-NEXT: [[OR:%[0-9]+]]:_(s8) = G_OR [[TRUNC]], [[TRUNC1]]
    ; CHECK-NEXT: [[ANYEXT:%[0-9]+]]:_(s32) = G_ANYEXT [[OR]](s8)
    ; CHECK-NEXT: $eax = COPY [[ANYEXT]](s32)
    ; CHECK-NEXT: RET 0
    %0(s32) = COPY $edx
    %1(s1) = G_TRUNC %0(s32)
    %2(s1) = G_OR %1, %1
    %3:_(s32) = G_ANYEXT %2
    $eax = COPY %3
    RET 0
...
---
name:            test_or_i8
alignment:       16
legalized:       false
regBankSelected: false
registers:
  - { id: 0, class: _, preferred-register: '' }
  - { id: 1, class: _, preferred-register: '' }
  - { id: 2, class: _, preferred-register: '' }
body:             |
  bb.1 (%ir-block.0):
    ; CHECK-LABEL: name: test_or_i8
    ; CHECK: [[COPY:%[0-9]+]]:_(s32) = COPY $edx
    ; CHECK-NEXT: [[TRUNC:%[0-9]+]]:_(s8) = G_TRUNC [[COPY]](s32)
    ; CHECK-NEXT: [[OR:%[0-9]+]]:_(s8) = G_OR [[TRUNC]], [[TRUNC]]
    ; CHECK-NEXT: [[ANYEXT:%[0-9]+]]:_(s32) = G_ANYEXT [[OR]](s8)
    ; CHECK-NEXT: $eax = COPY [[ANYEXT]](s32)
    ; CHECK-NEXT: RET 0
    %0(s32) = COPY $edx
    %1(s8) = G_TRUNC %0(s32)
    %2(s8) = G_OR %1, %1
    %3:_(s32) = G_ANYEXT %2
    $eax = COPY %3
    RET 0
...
---
name:            test_or_i16
alignment:       16
legalized:       false
regBankSelected: false
registers:
  - { id: 0, class: _ }
  - { id: 1, class: _ }
  - { id: 2, class: _ }
body:             |
  bb.1 (%ir-block.0):
    ; CHECK-LABEL: name: test_or_i16
    ; CHECK: [[COPY:%[0-9]+]]:_(s32) = COPY $edx
    ; CHECK-NEXT: [[TRUNC:%[0-9]+]]:_(s16) = G_TRUNC [[COPY]](s32)
    ; CHECK-NEXT: [[OR:%[0-9]+]]:_(s16) = G_OR [[TRUNC]], [[TRUNC]]
    ; CHECK-NEXT: [[ANYEXT:%[0-9]+]]:_(s32) = G_ANYEXT [[OR]](s16)
    ; CHECK-NEXT: $eax = COPY [[ANYEXT]](s32)
    ; CHECK-NEXT: RET 0
    %0(s32) = COPY $edx
    %1(s16) = G_TRUNC %0(s32)
    %2(s16) = G_OR %1, %1
    %3:_(s32) = G_ANYEXT %2
    $eax = COPY %3
    RET 0
...
---
name:            test_or_i27
alignment:       16
legalized:       false
regBankSelected: false
registers:
  - { id: 0, class: _ }
  - { id: 1, class: _ }
  - { id: 2, class: _ }
body:             |
  bb.1 (%ir-block.0):
    ; CHECK-LABEL: name: test_or_i27
    ; CHECK: [[COPY:%[0-9]+]]:_(s32) = COPY $edx
    ; CHECK-NEXT: [[OR:%[0-9]+]]:_(s32) = G_OR [[COPY]], [[COPY]]
    ; CHECK-NEXT: $eax = COPY [[OR]](s32)
    ; CHECK-NEXT: RET 0
    %0(s32) = COPY $edx
    %1(s27) = G_TRUNC %0(s32)
    %2(s27) = G_OR %1, %1
    %3:_(s32) = G_ANYEXT %2
    $eax = COPY %3
    RET 0
...
---
name:            test_or_i32
alignment:       16
legalized:       false
regBankSelected: false
registers:
  - { id: 0, class: _ }
  - { id: 1, class: _ }
  - { id: 2, class: _ }
body:             |
  bb.1 (%ir-block.0):
    ; CHECK-LABEL: name: test_or_i32
    ; CHECK: [[DEF:%[0-9]+]]:_(s32) = IMPLICIT_DEF
    ; CHECK-NEXT: [[DEF1:%[0-9]+]]:_(s32) = IMPLICIT_DEF
    ; CHECK-NEXT: [[OR:%[0-9]+]]:_(s32) = G_OR [[DEF]], [[DEF1]]
    ; CHECK-NEXT: $eax = COPY [[OR]](s32)
    ; CHECK-NEXT: RET 0
    %0(s32) = IMPLICIT_DEF
    %1(s32) = IMPLICIT_DEF
    %2(s32) = G_OR %0, %1
    $eax = COPY %2
    RET 0
...
---
name:            test_or_i42
alignment:       16
legalized:       false
regBankSelected: false
registers:
  - { id: 0, class: _ }
  - { id: 1, class: _ }
  - { id: 2, class: _ }
body:             |
  bb.1 (%ir-block.0):
    ; X64-LABEL: name: test_or_i42
    ; X64: [[COPY:%[0-9]+]]:_(s64) = COPY $rdx
    ; X64-NEXT: [[OR:%[0-9]+]]:_(s64) = G_OR [[COPY]], [[COPY]]
    ; X64-NEXT: $rax = COPY [[OR]](s64)
    ; X64-NEXT: RET 0
    ; X86-LABEL: name: test_or_i42
    ; X86: [[COPY:%[0-9]+]]:_(s64) = COPY $rdx
    ; X86-NEXT: [[UV:%[0-9]+]]:_(s32), [[UV1:%[0-9]+]]:_(s32) = G_UNMERGE_VALUES [[COPY]](s64)
    ; X86-NEXT: [[UV2:%[0-9]+]]:_(s32), [[UV3:%[0-9]+]]:_(s32) = G_UNMERGE_VALUES [[COPY]](s64)
    ; X86-NEXT: [[OR:%[0-9]+]]:_(s32) = G_OR [[UV]], [[UV2]]
    ; X86-NEXT: [[OR1:%[0-9]+]]:_(s32) = G_OR [[UV1]], [[UV3]]
    ; X86-NEXT: [[MV:%[0-9]+]]:_(s64) = G_MERGE_VALUES [[OR]](s32), [[OR1]](s32)
    ; X86-NEXT: $rax = COPY [[MV]](s64)
    ; X86-NEXT: RET 0
    %0(s64) = COPY $rdx
    %1(s42) = G_TRUNC %0(s64)
    %2(s42) = G_OR %1, %1
    %3:_(s64) = G_ANYEXT %2
    $rax = COPY %3
    RET 0
...
---
name:            test_or_i64
alignment:       16
legalized:       false
regBankSelected: false
registers:
  - { id: 0, class: _ }
  - { id: 1, class: _ }
  - { id: 2, class: _ }
body:             |
  bb.1 (%ir-block.0):
    ; X64-LABEL: name: test_or_i64
    ; X64: [[DEF:%[0-9]+]]:_(s64) = IMPLICIT_DEF
    ; X64-NEXT: [[DEF1:%[0-9]+]]:_(s64) = IMPLICIT_DEF
    ; X64-NEXT: [[OR:%[0-9]+]]:_(s64) = G_OR [[DEF]], [[DEF1]]
    ; X64-NEXT: $rax = COPY [[OR]](s64)
    ; X64-NEXT: RET 0
    ; X86-LABEL: name: test_or_i64
    ; X86: [[DEF:%[0-9]+]]:_(s64) = IMPLICIT_DEF
    ; X86-NEXT: [[DEF1:%[0-9]+]]:_(s64) = IMPLICIT_DEF
    ; X86-NEXT: [[UV:%[0-9]+]]:_(s32), [[UV1:%[0-9]+]]:_(s32) = G_UNMERGE_VALUES [[DEF]](s64)
    ; X86-NEXT: [[UV2:%[0-9]+]]:_(s32), [[UV3:%[0-9]+]]:_(s32) = G_UNMERGE_VALUES [[DEF1]](s64)
    ; X86-NEXT: [[OR:%[0-9]+]]:_(s32) = G_OR [[UV]], [[UV2]]
    ; X86-NEXT: [[OR1:%[0-9]+]]:_(s32) = G_OR [[UV1]], [[UV3]]
    ; X86-NEXT: [[MV:%[0-9]+]]:_(s64) = G_MERGE_VALUES [[OR]](s32), [[OR1]](s32)
    ; X86-NEXT: $rax = COPY [[MV]](s64)
    ; X86-NEXT: RET 0
    %0(s64) = IMPLICIT_DEF
    %1(s64) = IMPLICIT_DEF
    %2(s64) = G_OR %0, %1
    $rax = COPY %2
    RET 0
...