llvm/llvm/test/CodeGen/RISCV/GlobalISel/legalizer/legalize-select-rv64.mir

# NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
# RUN: llc -mtriple=riscv64 -run-pass=legalizer %s -o - \
# RUN: | FileCheck %s
---
name:            select_i8
body:             |
  bb.0.entry:
    ; CHECK-LABEL: name: select_i8
    ; CHECK: [[COPY:%[0-9]+]]:_(s64) = COPY $x10
    ; CHECK-NEXT: [[COPY1:%[0-9]+]]:_(s64) = COPY $x11
    ; CHECK-NEXT: [[COPY2:%[0-9]+]]:_(s64) = COPY $x12
    ; CHECK-NEXT: [[TRUNC:%[0-9]+]]:_(s32) = G_TRUNC [[COPY]](s64)
    ; CHECK-NEXT: [[TRUNC1:%[0-9]+]]:_(s32) = G_TRUNC [[COPY1]](s64)
    ; CHECK-NEXT: [[C:%[0-9]+]]:_(s64) = G_CONSTANT i64 1
    ; CHECK-NEXT: [[AND:%[0-9]+]]:_(s64) = G_AND [[COPY2]], [[C]]
    ; CHECK-NEXT: [[SELECT:%[0-9]+]]:_(s32) = G_SELECT [[AND]](s64), [[TRUNC]], [[TRUNC1]]
    ; CHECK-NEXT: [[ANYEXT:%[0-9]+]]:_(s64) = G_ANYEXT [[SELECT]](s32)
    ; CHECK-NEXT: $x10 = COPY [[ANYEXT]](s64)
    ; CHECK-NEXT: PseudoRET implicit $x10
    %0:_(s64) = COPY $x10
    %1:_(s64) = COPY $x11
    %2:_(s64) = COPY $x12
    %3:_(s8) = G_TRUNC %0(s64)
    %4:_(s8) = G_TRUNC %1(s64)
    %5:_(s1) = G_TRUNC %2(s64)
    %6:_(s8) = G_SELECT %5(s1), %3(s8), %4
    %7:_(s64) = G_ANYEXT %6(s8)
    $x10 = COPY %7(s64)
    PseudoRET implicit $x10

...
---
name:            select_i15
body:             |
  bb.0.entry:
    ; CHECK-LABEL: name: select_i15
    ; CHECK: [[COPY:%[0-9]+]]:_(s64) = COPY $x10
    ; CHECK-NEXT: [[COPY1:%[0-9]+]]:_(s64) = COPY $x11
    ; CHECK-NEXT: [[COPY2:%[0-9]+]]:_(s64) = COPY $x12
    ; CHECK-NEXT: [[TRUNC:%[0-9]+]]:_(s32) = G_TRUNC [[COPY]](s64)
    ; CHECK-NEXT: [[TRUNC1:%[0-9]+]]:_(s32) = G_TRUNC [[COPY1]](s64)
    ; CHECK-NEXT: [[C:%[0-9]+]]:_(s64) = G_CONSTANT i64 1
    ; CHECK-NEXT: [[AND:%[0-9]+]]:_(s64) = G_AND [[COPY2]], [[C]]
    ; CHECK-NEXT: [[SELECT:%[0-9]+]]:_(s32) = G_SELECT [[AND]](s64), [[TRUNC]], [[TRUNC1]]
    ; CHECK-NEXT: [[ANYEXT:%[0-9]+]]:_(s64) = G_ANYEXT [[SELECT]](s32)
    ; CHECK-NEXT: $x10 = COPY [[ANYEXT]](s64)
    ; CHECK-NEXT: PseudoRET implicit $x10
    %0:_(s64) = COPY $x10
    %1:_(s64) = COPY $x11
    %2:_(s64) = COPY $x12
    %3:_(s15) = G_TRUNC %0(s64)
    %4:_(s15) = G_TRUNC %1(s64)
    %5:_(s1) = G_TRUNC %2(s64)
    %6:_(s15) = G_SELECT %5(s1), %3(s15), %4
    %7:_(s64) = G_ANYEXT %6(s15)
    $x10 = COPY %7(s64)
    PseudoRET implicit $x10

...
---
name:            select_i16
body:             |
  bb.0.entry:
    ; CHECK-LABEL: name: select_i16
    ; CHECK: [[COPY:%[0-9]+]]:_(s64) = COPY $x10
    ; CHECK-NEXT: [[COPY1:%[0-9]+]]:_(s64) = COPY $x11
    ; CHECK-NEXT: [[COPY2:%[0-9]+]]:_(s64) = COPY $x12
    ; CHECK-NEXT: [[TRUNC:%[0-9]+]]:_(s32) = G_TRUNC [[COPY]](s64)
    ; CHECK-NEXT: [[TRUNC1:%[0-9]+]]:_(s32) = G_TRUNC [[COPY1]](s64)
    ; CHECK-NEXT: [[C:%[0-9]+]]:_(s64) = G_CONSTANT i64 1
    ; CHECK-NEXT: [[AND:%[0-9]+]]:_(s64) = G_AND [[COPY2]], [[C]]
    ; CHECK-NEXT: [[SELECT:%[0-9]+]]:_(s32) = G_SELECT [[AND]](s64), [[TRUNC]], [[TRUNC1]]
    ; CHECK-NEXT: [[ANYEXT:%[0-9]+]]:_(s64) = G_ANYEXT [[SELECT]](s32)
    ; CHECK-NEXT: $x10 = COPY [[ANYEXT]](s64)
    ; CHECK-NEXT: PseudoRET implicit $x10
    %0:_(s64) = COPY $x10
    %1:_(s64) = COPY $x11
    %2:_(s64) = COPY $x12
    %3:_(s16) = G_TRUNC %0(s64)
    %4:_(s16) = G_TRUNC %1(s64)
    %5:_(s1) = G_TRUNC %2(s64)
    %6:_(s16) = G_SELECT %5(s1), %3(s16), %4
    %7:_(s64) = G_ANYEXT %6(s16)
    $x10 = COPY %7(s64)
    PseudoRET implicit $x10

...
---
name:            select_i32
body:             |
  bb.0.entry:
    ; CHECK-LABEL: name: select_i32
    ; CHECK: [[COPY:%[0-9]+]]:_(s64) = COPY $x10
    ; CHECK-NEXT: [[COPY1:%[0-9]+]]:_(s64) = COPY $x11
    ; CHECK-NEXT: [[COPY2:%[0-9]+]]:_(s64) = COPY $x12
    ; CHECK-NEXT: [[TRUNC:%[0-9]+]]:_(s32) = G_TRUNC [[COPY]](s64)
    ; CHECK-NEXT: [[TRUNC1:%[0-9]+]]:_(s32) = G_TRUNC [[COPY1]](s64)
    ; CHECK-NEXT: [[C:%[0-9]+]]:_(s64) = G_CONSTANT i64 1
    ; CHECK-NEXT: [[AND:%[0-9]+]]:_(s64) = G_AND [[COPY2]], [[C]]
    ; CHECK-NEXT: [[SELECT:%[0-9]+]]:_(s32) = G_SELECT [[AND]](s64), [[TRUNC]], [[TRUNC1]]
    ; CHECK-NEXT: [[ANYEXT:%[0-9]+]]:_(s64) = G_ANYEXT [[SELECT]](s32)
    ; CHECK-NEXT: $x10 = COPY [[ANYEXT]](s64)
    ; CHECK-NEXT: PseudoRET implicit $x10
    %0:_(s64) = COPY $x10
    %1:_(s64) = COPY $x11
    %2:_(s64) = COPY $x12
    %3:_(s32) = G_TRUNC %0(s64)
    %4:_(s32) = G_TRUNC %1(s64)
    %5:_(s1) = G_TRUNC %2(s64)
    %6:_(s32) = G_SELECT %5(s1), %3(s32), %4
    %7:_(s64) = G_ANYEXT %6(s32)
    $x10 = COPY %7(s64)
    PseudoRET implicit $x10

...
---
name:            select_i64
body:             |
  bb.0.entry:
    ; CHECK-LABEL: name: select_i64
    ; CHECK: [[COPY:%[0-9]+]]:_(s64) = COPY $x10
    ; CHECK-NEXT: [[COPY1:%[0-9]+]]:_(s64) = COPY $x11
    ; CHECK-NEXT: [[COPY2:%[0-9]+]]:_(s64) = COPY $x12
    ; CHECK-NEXT: [[C:%[0-9]+]]:_(s64) = G_CONSTANT i64 1
    ; CHECK-NEXT: [[AND:%[0-9]+]]:_(s64) = G_AND [[COPY2]], [[C]]
    ; CHECK-NEXT: [[SELECT:%[0-9]+]]:_(s64) = G_SELECT [[AND]](s64), [[COPY]], [[COPY1]]
    ; CHECK-NEXT: $x10 = COPY [[SELECT]](s64)
    ; CHECK-NEXT: PseudoRET implicit $x10
    %0:_(s64) = COPY $x10
    %1:_(s64) = COPY $x11
    %2:_(s64) = COPY $x12
    %3:_(s1) = G_TRUNC %2(s64)
    %4:_(s64) = G_SELECT %3(s1), %0(s64), %1(s64)
    $x10 = COPY %4(s64)
    PseudoRET implicit $x10

...
---
name:            select_i72
body:             |
  bb.0.entry:
    ; CHECK-LABEL: name: select_i72
    ; CHECK: %xhi:_(s64) = COPY $x10
    ; CHECK-NEXT: %xlo:_(s64) = COPY $x11
    ; CHECK-NEXT: %yhi:_(s64) = COPY $x12
    ; CHECK-NEXT: %ylo:_(s64) = COPY $x13
    ; CHECK-NEXT: %c0:_(s64) = COPY $x14
    ; CHECK-NEXT: [[C:%[0-9]+]]:_(s64) = G_CONSTANT i64 1
    ; CHECK-NEXT: [[AND:%[0-9]+]]:_(s64) = G_AND %c0, [[C]]
    ; CHECK-NEXT: [[SELECT:%[0-9]+]]:_(s64) = G_SELECT [[AND]](s64), %xhi, %yhi
    ; CHECK-NEXT: [[C1:%[0-9]+]]:_(s64) = G_CONSTANT i64 1
    ; CHECK-NEXT: [[AND1:%[0-9]+]]:_(s64) = G_AND %c0, [[C1]]
    ; CHECK-NEXT: [[SELECT1:%[0-9]+]]:_(s64) = G_SELECT [[AND1]](s64), %xlo, %ylo
    ; CHECK-NEXT: $x10 = COPY [[SELECT]](s64)
    ; CHECK-NEXT: $x11 = COPY [[SELECT1]](s64)
    ; CHECK-NEXT: PseudoRET implicit $x10, implicit $x11
    %xhi:_(s64) = COPY $x10
    %xlo:_(s64) = COPY $x11
    %yhi:_(s64) = COPY $x12
    %ylo:_(s64) = COPY $x13
    %c0:_(s64) = COPY $x14
    %x0:_(s128) = G_MERGE_VALUES %xhi(s64), %xlo(s64)
    %y0:_(s128) = G_MERGE_VALUES %yhi(s64), %ylo(s64)
    %x:_(s72) = G_TRUNC %x0(s128)
    %y:_(s72) = G_TRUNC %y0(s128)
    %c:_(s1) = G_TRUNC %c0(s64)
    %z:_(s72) = G_SELECT %c(s1), %x(s72), %y
    %z0:_(s128) = G_ANYEXT %z(s72)
    %zhi:_(s64), %zlo:_(s64) = G_UNMERGE_VALUES %z0(s128)
    $x10 = COPY %zhi(s64)
    $x11 = COPY %zlo(s64)
    PseudoRET implicit $x10, implicit $x11

...
---
name:            select_i128
body:             |
  bb.0.entry:
    ; CHECK-LABEL: name: select_i128
    ; CHECK: %xhi:_(s64) = COPY $x10
    ; CHECK-NEXT: %xlo:_(s64) = COPY $x11
    ; CHECK-NEXT: %yhi:_(s64) = COPY $x12
    ; CHECK-NEXT: %ylo:_(s64) = COPY $x13
    ; CHECK-NEXT: %c0:_(s64) = COPY $x14
    ; CHECK-NEXT: [[C:%[0-9]+]]:_(s64) = G_CONSTANT i64 1
    ; CHECK-NEXT: [[AND:%[0-9]+]]:_(s64) = G_AND %c0, [[C]]
    ; CHECK-NEXT: [[SELECT:%[0-9]+]]:_(s64) = G_SELECT [[AND]](s64), %xhi, %yhi
    ; CHECK-NEXT: [[C1:%[0-9]+]]:_(s64) = G_CONSTANT i64 1
    ; CHECK-NEXT: [[AND1:%[0-9]+]]:_(s64) = G_AND %c0, [[C1]]
    ; CHECK-NEXT: [[SELECT1:%[0-9]+]]:_(s64) = G_SELECT [[AND1]](s64), %xlo, %ylo
    ; CHECK-NEXT: $x10 = COPY [[SELECT]](s64)
    ; CHECK-NEXT: $x11 = COPY [[SELECT1]](s64)
    ; CHECK-NEXT: PseudoRET implicit $x10, implicit $x11
    %xhi:_(s64) = COPY $x10
    %xlo:_(s64) = COPY $x11
    %yhi:_(s64) = COPY $x12
    %ylo:_(s64) = COPY $x13
    %c0:_(s64) = COPY $x14
    %x:_(s128) = G_MERGE_VALUES %xhi(s64), %xlo(s64)
    %y:_(s128) = G_MERGE_VALUES %yhi(s64), %ylo(s64)
    %c:_(s1) = G_TRUNC %c0(s64)
    %z:_(s128) = G_SELECT %c(s1), %x(s128), %y
    %zhi:_(s64), %zlo:_(s64) = G_UNMERGE_VALUES %z(s128)
    $x10 = COPY %zhi(s64)
    $x11 = COPY %zlo(s64)
    PseudoRET implicit $x10, implicit $x11

...
---
name:            select_i192
body:             |
  bb.0.entry:
    ; CHECK-LABEL: name: select_i192
    ; CHECK: %yhi:_(s64) = COPY $x13
    ; CHECK-NEXT: %ymid:_(s64) = COPY $x14
    ; CHECK-NEXT: %ylo:_(s64) = COPY $x15
    ; CHECK-NEXT: $x10 = COPY %yhi(s64)
    ; CHECK-NEXT: $x11 = COPY %ymid(s64)
    ; CHECK-NEXT: $x12 = COPY %ylo(s64)
    ; CHECK-NEXT: PseudoRET implicit $x10, implicit $x11, implicit $x12
    %xhi:_(s64) = COPY $x10
    %xmid:_(s64) = COPY $x11
    %xlo:_(s64) = COPY $x12
    %yhi:_(s64) = COPY $x13
    %ymid:_(s64) = COPY $x14
    %ylo:_(s64) = COPY $x15
    %c0:_(s64) = COPY $x16
    %x:_(s192) = G_MERGE_VALUES %xhi(s64), %xmid(s64), %xlo(s64)
    %y:_(s192) = G_MERGE_VALUES %yhi(s64), %ymid(s64), %ylo(s64)
    %c:_(s1) = G_TRUNC %c0(s64)
    %z:_(s192) = G_SELECT %c(s1), %x(s192), %y
    %zhi:_(s64), %zmid:_(s64), %zlo:_(s64) = G_UNMERGE_VALUES %y(s192)
    $x10 = COPY %zhi(s64)
    $x11 = COPY %zmid(s64)
    $x12 = COPY %zlo(s64)
    PseudoRET implicit $x10, implicit $x11, implicit $x12

...
---
name:            select_ptr
body:             |
  bb.0.entry:
    ; CHECK-LABEL: name: select_ptr
    ; CHECK: [[COPY:%[0-9]+]]:_(p0) = COPY $x10
    ; CHECK-NEXT: [[COPY1:%[0-9]+]]:_(p0) = COPY $x11
    ; CHECK-NEXT: [[COPY2:%[0-9]+]]:_(s64) = COPY $x12
    ; CHECK-NEXT: [[C:%[0-9]+]]:_(s64) = G_CONSTANT i64 1
    ; CHECK-NEXT: [[AND:%[0-9]+]]:_(s64) = G_AND [[COPY2]], [[C]]
    ; CHECK-NEXT: [[SELECT:%[0-9]+]]:_(p0) = G_SELECT [[AND]](s64), [[COPY]], [[COPY1]]
    ; CHECK-NEXT: $x10 = COPY [[SELECT]](p0)
    ; CHECK-NEXT: PseudoRET implicit $x10
    %0:_(p0) = COPY $x10
    %1:_(p0) = COPY $x11
    %2:_(s64) = COPY $x12
    %3:_(s1) = G_TRUNC %2(s64)
    %4:_(p0) = G_SELECT %3(s1), %0(p0), %1(p0)
    $x10 = COPY %4(p0)
    PseudoRET implicit $x10

...