llvm/llvm/test/CodeGen/RISCV/GlobalISel/legalizer/legalize-mul-rv32.mir

# NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
# RUN: llc -mtriple=riscv32 -run-pass=legalizer %s -o - \
# RUN: | FileCheck %s
---
name:            mul_i7
body:             |
  bb.0.entry:
    ; CHECK-LABEL: name: mul_i7
    ; CHECK: [[COPY:%[0-9]+]]:_(s32) = COPY $x10
    ; CHECK-NEXT: [[COPY1:%[0-9]+]]:_(s32) = COPY $x11
    ; CHECK-NEXT: ADJCALLSTACKDOWN 0, 0, implicit-def $x2, implicit $x2
    ; CHECK-NEXT: $x10 = COPY [[COPY]](s32)
    ; CHECK-NEXT: $x11 = COPY [[COPY1]](s32)
    ; CHECK-NEXT: PseudoCALL target-flags(riscv-call) &__mulsi3, csr_ilp32_lp64, implicit-def $x1, implicit $x10, implicit $x11, implicit-def $x10
    ; CHECK-NEXT: ADJCALLSTACKUP 0, 0, implicit-def $x2, implicit $x2
    ; CHECK-NEXT: [[COPY2:%[0-9]+]]:_(s32) = COPY $x10
    ; CHECK-NEXT: $x10 = COPY [[COPY2]](s32)
    ; CHECK-NEXT: PseudoRET implicit $x10
    %0:_(s32) = COPY $x10
    %1:_(s32) = COPY $x11
    %2:_(s7) = G_TRUNC %0(s32)
    %3:_(s7) = G_TRUNC %1(s32)
    %4:_(s7) = G_MUL %2, %3
    %5:_(s32) = G_ANYEXT %4(s7)
    $x10 = COPY %5(s32)
    PseudoRET implicit $x10

...
---
name:            mul_i8
body:             |
  bb.0.entry:
    ; CHECK-LABEL: name: mul_i8
    ; CHECK: [[COPY:%[0-9]+]]:_(s32) = COPY $x10
    ; CHECK-NEXT: [[COPY1:%[0-9]+]]:_(s32) = COPY $x11
    ; CHECK-NEXT: ADJCALLSTACKDOWN 0, 0, implicit-def $x2, implicit $x2
    ; CHECK-NEXT: $x10 = COPY [[COPY]](s32)
    ; CHECK-NEXT: $x11 = COPY [[COPY1]](s32)
    ; CHECK-NEXT: PseudoCALL target-flags(riscv-call) &__mulsi3, csr_ilp32_lp64, implicit-def $x1, implicit $x10, implicit $x11, implicit-def $x10
    ; CHECK-NEXT: ADJCALLSTACKUP 0, 0, implicit-def $x2, implicit $x2
    ; CHECK-NEXT: [[COPY2:%[0-9]+]]:_(s32) = COPY $x10
    ; CHECK-NEXT: $x10 = COPY [[COPY2]](s32)
    ; CHECK-NEXT: PseudoRET implicit $x10
    %0:_(s32) = COPY $x10
    %1:_(s32) = COPY $x11
    %2:_(s8) = G_TRUNC %0(s32)
    %3:_(s8) = G_TRUNC %1(s32)
    %4:_(s8) = G_MUL %2, %3
    %5:_(s32) = G_ANYEXT %4(s8)
    $x10 = COPY %5(s32)
    PseudoRET implicit $x10

...
---
name:            mul_i16
body:             |
  bb.0.entry:
    ; CHECK-LABEL: name: mul_i16
    ; CHECK: [[COPY:%[0-9]+]]:_(s32) = COPY $x10
    ; CHECK-NEXT: [[COPY1:%[0-9]+]]:_(s32) = COPY $x11
    ; CHECK-NEXT: ADJCALLSTACKDOWN 0, 0, implicit-def $x2, implicit $x2
    ; CHECK-NEXT: $x10 = COPY [[COPY]](s32)
    ; CHECK-NEXT: $x11 = COPY [[COPY1]](s32)
    ; CHECK-NEXT: PseudoCALL target-flags(riscv-call) &__mulsi3, csr_ilp32_lp64, implicit-def $x1, implicit $x10, implicit $x11, implicit-def $x10
    ; CHECK-NEXT: ADJCALLSTACKUP 0, 0, implicit-def $x2, implicit $x2
    ; CHECK-NEXT: [[COPY2:%[0-9]+]]:_(s32) = COPY $x10
    ; CHECK-NEXT: $x10 = COPY [[COPY2]](s32)
    ; CHECK-NEXT: PseudoRET implicit $x10
    %0:_(s32) = COPY $x10
    %1:_(s32) = COPY $x11
    %2:_(s16) = G_TRUNC %0(s32)
    %3:_(s16) = G_TRUNC %1(s32)
    %4:_(s16) = G_MUL %2, %3
    %5:_(s32) = G_ANYEXT %4(s16)
    $x10 = COPY %5(s32)
    PseudoRET implicit $x10

...
---
name:            mul_i32
body:             |
  bb.0.entry:
    ; CHECK-LABEL: name: mul_i32
    ; CHECK: [[COPY:%[0-9]+]]:_(s32) = COPY $x10
    ; CHECK-NEXT: [[COPY1:%[0-9]+]]:_(s32) = COPY $x11
    ; CHECK-NEXT: ADJCALLSTACKDOWN 0, 0, implicit-def $x2, implicit $x2
    ; CHECK-NEXT: $x10 = COPY [[COPY]](s32)
    ; CHECK-NEXT: $x11 = COPY [[COPY1]](s32)
    ; CHECK-NEXT: PseudoCALL target-flags(riscv-call) &__mulsi3, csr_ilp32_lp64, implicit-def $x1, implicit $x10, implicit $x11, implicit-def $x10
    ; CHECK-NEXT: ADJCALLSTACKUP 0, 0, implicit-def $x2, implicit $x2
    ; CHECK-NEXT: [[COPY2:%[0-9]+]]:_(s32) = COPY $x10
    ; CHECK-NEXT: $x10 = COPY [[COPY2]](s32)
    ; CHECK-NEXT: PseudoRET implicit $x10
    %0:_(s32) = COPY $x10
    %1:_(s32) = COPY $x11
    %2:_(s32) = G_MUL %0, %1
    $x10 = COPY %2(s32)
    PseudoRET implicit $x10

...
---
name:            mul_i64
body:             |
  bb.0.entry:
    ; CHECK-LABEL: name: mul_i64
    ; CHECK: %lo1:_(s32) = COPY $x10
    ; CHECK-NEXT: %hi1:_(s32) = COPY $x11
    ; CHECK-NEXT: %lo2:_(s32) = COPY $x12
    ; CHECK-NEXT: %hi2:_(s32) = COPY $x13
    ; CHECK-NEXT: ADJCALLSTACKDOWN 0, 0, implicit-def $x2, implicit $x2
    ; CHECK-NEXT: $x10 = COPY %lo1(s32)
    ; CHECK-NEXT: $x11 = COPY %hi1(s32)
    ; CHECK-NEXT: $x12 = COPY %lo2(s32)
    ; CHECK-NEXT: $x13 = COPY %hi2(s32)
    ; CHECK-NEXT: PseudoCALL target-flags(riscv-call) &__muldi3, csr_ilp32_lp64, implicit-def $x1, implicit $x10, implicit $x11, implicit $x12, implicit $x13, implicit-def $x10, implicit-def $x11
    ; CHECK-NEXT: ADJCALLSTACKUP 0, 0, implicit-def $x2, implicit $x2
    ; CHECK-NEXT: [[COPY:%[0-9]+]]:_(s32) = COPY $x10
    ; CHECK-NEXT: [[COPY1:%[0-9]+]]:_(s32) = COPY $x11
    ; CHECK-NEXT: $x10 = COPY [[COPY]](s32)
    ; CHECK-NEXT: $x11 = COPY [[COPY1]](s32)
    ; CHECK-NEXT: PseudoRET implicit $x10, implicit $x11
    %lo1:_(s32) = COPY $x10
    %hi1:_(s32) = COPY $x11
    %lo2:_(s32) = COPY $x12
    %hi2:_(s32) = COPY $x13
    %x1:_(s64) = G_MERGE_VALUES %lo1(s32), %hi1(s32)
    %x2:_(s64) = G_MERGE_VALUES %lo2(s32), %hi2(s32)
    %y:_(s64) = G_MUL %x1, %x2
    %loy:_(s32), %hiy:_(s32) = G_UNMERGE_VALUES %y(s64)
    $x10 = COPY %loy(s32)
    $x11 = COPY %hiy(s32)
    PseudoRET implicit $x10, implicit $x11

...
---
name:            smulh_i32
body:             |
  bb.0.entry:
    ; CHECK-LABEL: name: smulh_i32
    ; CHECK: [[COPY:%[0-9]+]]:_(s32) = COPY $x10
    ; CHECK-NEXT: [[COPY1:%[0-9]+]]:_(s32) = COPY $x11
    ; CHECK-NEXT: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 31
    ; CHECK-NEXT: [[ASHR:%[0-9]+]]:_(s32) = G_ASHR [[COPY]], [[C]](s32)
    ; CHECK-NEXT: [[ASHR1:%[0-9]+]]:_(s32) = G_ASHR [[COPY1]], [[C]](s32)
    ; CHECK-NEXT: ADJCALLSTACKDOWN 0, 0, implicit-def $x2, implicit $x2
    ; CHECK-NEXT: $x10 = COPY [[COPY]](s32)
    ; CHECK-NEXT: $x11 = COPY [[ASHR]](s32)
    ; CHECK-NEXT: $x12 = COPY [[COPY1]](s32)
    ; CHECK-NEXT: $x13 = COPY [[ASHR1]](s32)
    ; CHECK-NEXT: PseudoCALL target-flags(riscv-call) &__muldi3, csr_ilp32_lp64, implicit-def $x1, implicit $x10, implicit $x11, implicit $x12, implicit $x13, implicit-def $x10, implicit-def $x11
    ; CHECK-NEXT: ADJCALLSTACKUP 0, 0, implicit-def $x2, implicit $x2
    ; CHECK-NEXT: [[COPY2:%[0-9]+]]:_(s32) = COPY $x11
    ; CHECK-NEXT: $x10 = COPY [[COPY2]](s32)
    ; CHECK-NEXT: PseudoRET implicit $x10
    %0:_(s32) = COPY $x10
    %1:_(s32) = COPY $x11
    %2:_(s32) = G_SMULH %0, %1
    $x10 = COPY %2(s32)
    PseudoRET implicit $x10

...