llvm/llvm/test/CodeGen/RISCV/GlobalISel/instruction-select/alu_m-rv64.mir

# NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
# RUN: llc -mtriple=riscv64 -mattr=+m -run-pass=instruction-select -simplify-mir -verify-machineinstrs %s -o - \
# RUN: | FileCheck -check-prefix=RV64I %s

---
name:            mul_i32
legalized:       true
regBankSelected: true
tracksRegLiveness: true
body:             |
  bb.0.entry:
    liveins: $x10, $x11

    ; RV64I-LABEL: name: mul_i32
    ; RV64I: liveins: $x10, $x11
    ; RV64I-NEXT: {{  $}}
    ; RV64I-NEXT: [[COPY:%[0-9]+]]:gpr = COPY $x10
    ; RV64I-NEXT: [[COPY1:%[0-9]+]]:gpr = COPY $x11
    ; RV64I-NEXT: [[MULW:%[0-9]+]]:gpr = MULW [[COPY]], [[COPY1]]
    ; RV64I-NEXT: $x10 = COPY [[MULW]]
    ; RV64I-NEXT: PseudoRET implicit $x10
    %0:gprb(s64) = COPY $x10
    %1:gprb(s32) = G_TRUNC %0(s64)
    %2:gprb(s64) = COPY $x11
    %3:gprb(s32) = G_TRUNC %2(s64)
    %4:gprb(s32) = G_MUL %1, %3
    %5:gprb(s64) = G_ANYEXT %4(s32)
    $x10 = COPY %5(s64)
    PseudoRET implicit $x10

...
---
name:            sdiv_i32
legalized:       true
regBankSelected: true
tracksRegLiveness: true
body:             |
  bb.0.entry:
    liveins: $x10, $x11

    ; RV64I-LABEL: name: sdiv_i32
    ; RV64I: liveins: $x10, $x11
    ; RV64I-NEXT: {{  $}}
    ; RV64I-NEXT: [[COPY:%[0-9]+]]:gpr = COPY $x10
    ; RV64I-NEXT: [[COPY1:%[0-9]+]]:gpr = COPY $x11
    ; RV64I-NEXT: [[DIVW:%[0-9]+]]:gpr = DIVW [[COPY]], [[COPY1]]
    ; RV64I-NEXT: $x10 = COPY [[DIVW]]
    ; RV64I-NEXT: PseudoRET implicit $x10
    %0:gprb(s64) = COPY $x10
    %1:gprb(s32) = G_TRUNC %0(s64)
    %2:gprb(s64) = COPY $x11
    %3:gprb(s32) = G_TRUNC %2(s64)
    %4:gprb(s32) = G_SDIV %1, %3
    %5:gprb(s64) = G_ANYEXT %4(s32)
    $x10 = COPY %5(s64)
    PseudoRET implicit $x10

...
---
name:            srem_i32
legalized:       true
regBankSelected: true
tracksRegLiveness: true
body:             |
  bb.0.entry:
    liveins: $x10, $x11

    ; RV64I-LABEL: name: srem_i32
    ; RV64I: liveins: $x10, $x11
    ; RV64I-NEXT: {{  $}}
    ; RV64I-NEXT: [[COPY:%[0-9]+]]:gpr = COPY $x10
    ; RV64I-NEXT: [[COPY1:%[0-9]+]]:gpr = COPY $x11
    ; RV64I-NEXT: [[REMW:%[0-9]+]]:gpr = REMW [[COPY]], [[COPY1]]
    ; RV64I-NEXT: $x10 = COPY [[REMW]]
    ; RV64I-NEXT: PseudoRET implicit $x10
    %0:gprb(s64) = COPY $x10
    %1:gprb(s32) = G_TRUNC %0(s64)
    %2:gprb(s64) = COPY $x11
    %3:gprb(s32) = G_TRUNC %2(s64)
    %4:gprb(s32) = G_SREM %1, %3
    %5:gprb(s64) = G_ANYEXT %4(s32)
    $x10 = COPY %5(s64)
    PseudoRET implicit $x10

...
---
name:            udiv_i32
legalized:       true
regBankSelected: true
tracksRegLiveness: true
body:             |
  bb.0.entry:
    liveins: $x10, $x11

    ; RV64I-LABEL: name: udiv_i32
    ; RV64I: liveins: $x10, $x11
    ; RV64I-NEXT: {{  $}}
    ; RV64I-NEXT: [[COPY:%[0-9]+]]:gpr = COPY $x10
    ; RV64I-NEXT: [[COPY1:%[0-9]+]]:gpr = COPY $x11
    ; RV64I-NEXT: [[DIVUW:%[0-9]+]]:gpr = DIVUW [[COPY]], [[COPY1]]
    ; RV64I-NEXT: $x10 = COPY [[DIVUW]]
    ; RV64I-NEXT: PseudoRET implicit $x10
    %0:gprb(s64) = COPY $x10
    %1:gprb(s32) = G_TRUNC %0(s64)
    %2:gprb(s64) = COPY $x11
    %3:gprb(s32) = G_TRUNC %2(s64)
    %4:gprb(s32) = G_UDIV %1, %3
    %5:gprb(s64) = G_ANYEXT %4(s32)
    $x10 = COPY %5(s64)
    PseudoRET implicit $x10

...
---
name:            urem_i32
legalized:       true
regBankSelected: true
tracksRegLiveness: true
body:             |
  bb.0.entry:
    liveins: $x10, $x11

    ; RV64I-LABEL: name: urem_i32
    ; RV64I: liveins: $x10, $x11
    ; RV64I-NEXT: {{  $}}
    ; RV64I-NEXT: [[COPY:%[0-9]+]]:gpr = COPY $x10
    ; RV64I-NEXT: [[COPY1:%[0-9]+]]:gpr = COPY $x11
    ; RV64I-NEXT: [[REMUW:%[0-9]+]]:gpr = REMUW [[COPY]], [[COPY1]]
    ; RV64I-NEXT: $x10 = COPY [[REMUW]]
    ; RV64I-NEXT: PseudoRET implicit $x10
    %0:gprb(s64) = COPY $x10
    %1:gprb(s32) = G_TRUNC %0(s64)
    %2:gprb(s64) = COPY $x11
    %3:gprb(s32) = G_TRUNC %2(s64)
    %4:gprb(s32) = G_UREM %1, %3
    %5:gprb(s64) = G_ANYEXT %4(s32)
    $x10 = COPY %5(s64)
    PseudoRET implicit $x10

...
---
name:            mul_i64
legalized:       true
regBankSelected: true
tracksRegLiveness: true
body:             |
  bb.0.entry:
    liveins: $x10, $x11

    ; RV64I-LABEL: name: mul_i64
    ; RV64I: liveins: $x10, $x11
    ; RV64I-NEXT: {{  $}}
    ; RV64I-NEXT: [[COPY:%[0-9]+]]:gpr = COPY $x10
    ; RV64I-NEXT: [[COPY1:%[0-9]+]]:gpr = COPY $x11
    ; RV64I-NEXT: [[MUL:%[0-9]+]]:gpr = MUL [[COPY]], [[COPY1]]
    ; RV64I-NEXT: $x10 = COPY [[MUL]]
    ; RV64I-NEXT: PseudoRET implicit $x10
    %0:gprb(s64) = COPY $x10
    %1:gprb(s64) = COPY $x11
    %2:gprb(s64) = G_MUL %0, %1
    $x10 = COPY %2(s64)
    PseudoRET implicit $x10

...
---
name:            sdiv_i64
legalized:       true
regBankSelected: true
tracksRegLiveness: true
body:             |
  bb.0.entry:
    liveins: $x10, $x11

    ; RV64I-LABEL: name: sdiv_i64
    ; RV64I: liveins: $x10, $x11
    ; RV64I-NEXT: {{  $}}
    ; RV64I-NEXT: [[COPY:%[0-9]+]]:gpr = COPY $x10
    ; RV64I-NEXT: [[COPY1:%[0-9]+]]:gpr = COPY $x11
    ; RV64I-NEXT: [[DIV:%[0-9]+]]:gpr = DIV [[COPY]], [[COPY1]]
    ; RV64I-NEXT: $x10 = COPY [[DIV]]
    ; RV64I-NEXT: PseudoRET implicit $x10
    %0:gprb(s64) = COPY $x10
    %1:gprb(s64) = COPY $x11
    %2:gprb(s64) = G_SDIV %0, %1
    $x10 = COPY %2(s64)
    PseudoRET implicit $x10

...
---
name:            srem_i64
legalized:       true
regBankSelected: true
tracksRegLiveness: true
body:             |
  bb.0.entry:
    liveins: $x10, $x11

    ; RV64I-LABEL: name: srem_i64
    ; RV64I: liveins: $x10, $x11
    ; RV64I-NEXT: {{  $}}
    ; RV64I-NEXT: [[COPY:%[0-9]+]]:gpr = COPY $x10
    ; RV64I-NEXT: [[COPY1:%[0-9]+]]:gpr = COPY $x11
    ; RV64I-NEXT: [[REM:%[0-9]+]]:gpr = REM [[COPY]], [[COPY1]]
    ; RV64I-NEXT: $x10 = COPY [[REM]]
    ; RV64I-NEXT: PseudoRET implicit $x10
    %0:gprb(s64) = COPY $x10
    %1:gprb(s64) = COPY $x11
    %2:gprb(s64) = G_SREM %0, %1
    $x10 = COPY %2(s64)
    PseudoRET implicit $x10

...
---
name:            smulh_i64
legalized:       true
regBankSelected: true
tracksRegLiveness: true
body:             |
  bb.0.entry:
    liveins: $x10, $x11

    ; RV64I-LABEL: name: smulh_i64
    ; RV64I: liveins: $x10, $x11
    ; RV64I-NEXT: {{  $}}
    ; RV64I-NEXT: [[COPY:%[0-9]+]]:gpr = COPY $x10
    ; RV64I-NEXT: [[COPY1:%[0-9]+]]:gpr = COPY $x11
    ; RV64I-NEXT: [[MULH:%[0-9]+]]:gpr = MULH [[COPY]], [[COPY1]]
    ; RV64I-NEXT: $x10 = COPY [[MULH]]
    ; RV64I-NEXT: PseudoRET implicit $x10
    %0:gprb(s64) = COPY $x10
    %1:gprb(s64) = COPY $x11
    %2:gprb(s64) = G_SMULH %0, %1
    $x10 = COPY %2(s64)
    PseudoRET implicit $x10

...
---
name:            udiv_i64
legalized:       true
regBankSelected: true
tracksRegLiveness: true
body:             |
  bb.0.entry:
    liveins: $x10, $x11

    ; RV64I-LABEL: name: udiv_i64
    ; RV64I: liveins: $x10, $x11
    ; RV64I-NEXT: {{  $}}
    ; RV64I-NEXT: [[COPY:%[0-9]+]]:gpr = COPY $x10
    ; RV64I-NEXT: [[COPY1:%[0-9]+]]:gpr = COPY $x11
    ; RV64I-NEXT: [[DIVU:%[0-9]+]]:gpr = DIVU [[COPY]], [[COPY1]]
    ; RV64I-NEXT: $x10 = COPY [[DIVU]]
    ; RV64I-NEXT: PseudoRET implicit $x10
    %0:gprb(s64) = COPY $x10
    %1:gprb(s64) = COPY $x11
    %2:gprb(s64) = G_UDIV %0, %1
    $x10 = COPY %2(s64)
    PseudoRET implicit $x10

...
---
name:            urem_i64
legalized:       true
regBankSelected: true
tracksRegLiveness: true
body:             |
  bb.0.entry:
    liveins: $x10, $x11

    ; RV64I-LABEL: name: urem_i64
    ; RV64I: liveins: $x10, $x11
    ; RV64I-NEXT: {{  $}}
    ; RV64I-NEXT: [[COPY:%[0-9]+]]:gpr = COPY $x10
    ; RV64I-NEXT: [[COPY1:%[0-9]+]]:gpr = COPY $x11
    ; RV64I-NEXT: [[REMU:%[0-9]+]]:gpr = REMU [[COPY]], [[COPY1]]
    ; RV64I-NEXT: $x10 = COPY [[REMU]]
    ; RV64I-NEXT: PseudoRET implicit $x10
    %0:gprb(s64) = COPY $x10
    %1:gprb(s64) = COPY $x11
    %2:gprb(s64) = G_UREM %0, %1
    $x10 = COPY %2(s64)
    PseudoRET implicit $x10

...
---
name:            mul_i128
legalized:       true
regBankSelected: true
tracksRegLiveness: true
body:             |
  bb.0.entry:
    liveins: $x10, $x11, $x12, $x13

    ; RV64I-LABEL: name: mul_i128
    ; RV64I: liveins: $x10, $x11, $x12, $x13
    ; RV64I-NEXT: {{  $}}
    ; RV64I-NEXT: [[COPY:%[0-9]+]]:gpr = COPY $x10
    ; RV64I-NEXT: [[COPY1:%[0-9]+]]:gpr = COPY $x11
    ; RV64I-NEXT: [[COPY2:%[0-9]+]]:gpr = COPY $x12
    ; RV64I-NEXT: [[COPY3:%[0-9]+]]:gpr = COPY $x13
    ; RV64I-NEXT: [[MUL:%[0-9]+]]:gpr = MUL [[COPY]], [[COPY2]]
    ; RV64I-NEXT: [[MUL1:%[0-9]+]]:gpr = MUL [[COPY1]], [[COPY2]]
    ; RV64I-NEXT: [[MUL2:%[0-9]+]]:gpr = MUL [[COPY]], [[COPY3]]
    ; RV64I-NEXT: [[MULHU:%[0-9]+]]:gpr = MULHU [[COPY]], [[COPY2]]
    ; RV64I-NEXT: [[ADD:%[0-9]+]]:gpr = ADD [[MUL1]], [[MUL2]]
    ; RV64I-NEXT: [[ADD1:%[0-9]+]]:gpr = ADD [[ADD]], [[MULHU]]
    ; RV64I-NEXT: $x10 = COPY [[MUL]]
    ; RV64I-NEXT: $x11 = COPY [[ADD1]]
    ; RV64I-NEXT: PseudoRET implicit $x10, implicit $x11
    %0:gprb(s64) = COPY $x10
    %1:gprb(s64) = COPY $x11
    %2:gprb(s64) = COPY $x12
    %3:gprb(s64) = COPY $x13
    %4:gprb(s64) = G_MUL %0, %2
    %5:gprb(s64) = G_MUL %1, %2
    %6:gprb(s64) = G_MUL %0, %3
    %7:gprb(s64) = G_UMULH %0, %2
    %8:gprb(s64) = G_ADD %5, %6
    %9:gprb(s64) = G_ADD %8, %7
    $x10 = COPY %4(s64)
    $x11 = COPY %9(s64)
    PseudoRET implicit $x10, implicit $x11

...