diff --git a/llvm/lib/Target/RISCV/GISel/RISCVLegalizerInfo.cpp b/llvm/lib/Target/RISCV/GISel/RISCVLegalizerInfo.cpp --- a/llvm/lib/Target/RISCV/GISel/RISCVLegalizerInfo.cpp +++ b/llvm/lib/Target/RISCV/GISel/RISCVLegalizerInfo.cpp @@ -97,5 +97,31 @@ .clampScalar(0, XLenLLT, XLenLLT) .clampScalar(1, XLenLLT, XLenLLT); + if (ST.hasStdExtM() || ST.hasStdExtZmmul()) { + getActionDefinitionsBuilder(G_MUL) + .legalFor({XLenLLT}) + .widenScalarToNextPow2(0) + .clampScalar(0, XLenLLT, XLenLLT); + + getActionDefinitionsBuilder({G_SMULO, G_UMULO}) + .widenScalarToNextPow2(0) + .clampScalar(0, XLenLLT, XLenLLT) + .lower(); + + getActionDefinitionsBuilder({G_SMULH, G_UMULH}).legalFor({XLenLLT}).lower(); + } else { + getActionDefinitionsBuilder(G_MUL) + .libcallFor({XLenLLT}) + .widenScalarToNextPow2(0) + .clampScalar(0, XLenLLT, XLenLLT); + + getActionDefinitionsBuilder({G_SMULO, G_UMULO}) + .widenScalarToNextPow2(0) + .clampScalar(0, XLenLLT, XLenLLT) + .lower(); + + getActionDefinitionsBuilder({G_SMULH, G_UMULH}).lowerFor({XLenLLT}); + } + getLegacyLegalizerInfo().computeTables(); } diff --git a/llvm/test/CodeGen/RISCV/GlobalISel/legalizer/rv32/legalize-mul-ext.mir b/llvm/test/CodeGen/RISCV/GlobalISel/legalizer/rv32/legalize-mul-ext.mir new file mode 100644 --- /dev/null +++ b/llvm/test/CodeGen/RISCV/GlobalISel/legalizer/rv32/legalize-mul-ext.mir @@ -0,0 +1,443 @@ +# NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py +# RUN: llc -mattr=+m -mtriple=riscv32 -run-pass=legalizer %s -o - \ +# RUN: | FileCheck %s -check-prefix=CHECK-M +# RUN: llc -mattr=+zmmul -mtriple=riscv32 -run-pass=legalizer %s -o - \ +# RUN: | FileCheck %s -check-prefix=CHECK-ZMMUL +--- +name: mul_i7 +body: | + bb.0.entry: + ; CHECK-I-LABEL: name: mul_i7 + ; CHECK-I: [[COPY:%[0-9]+]]:_(s32) = COPY $x10 + ; CHECK-I-NEXT: [[COPY1:%[0-9]+]]:_(s32) = COPY $x11 + ; CHECK-I-NEXT: $x10 = COPY [[COPY]](s32) + ; CHECK-I-NEXT: $x11 = COPY [[COPY1]](s32) + ; CHECK-I-NEXT: PseudoCALL target-flags(riscv-call) &__mulsi3, implicit-def $x1, implicit $x10, implicit $x11, implicit-def $x10 + ; CHECK-I-NEXT: [[COPY2:%[0-9]+]]:_(s32) = COPY $x10 + ; CHECK-I-NEXT: $x10 = COPY [[COPY2]](s32) + ; CHECK-I-NEXT: PseudoRET implicit $x10 + ; + ; CHECK-M-LABEL: name: mul_i7 + ; CHECK-M: [[COPY:%[0-9]+]]:_(s32) = COPY $x10 + ; CHECK-M-NEXT: [[COPY1:%[0-9]+]]:_(s32) = COPY $x11 + ; CHECK-M-NEXT: [[MUL:%[0-9]+]]:_(s32) = G_MUL [[COPY]], [[COPY1]] + ; CHECK-M-NEXT: $x10 = COPY [[MUL]](s32) + ; CHECK-M-NEXT: PseudoRET implicit $x10 + ; + ; CHECK-ZMMUL-LABEL: name: mul_i7 + ; CHECK-ZMMUL: [[COPY:%[0-9]+]]:_(s32) = COPY $x10 + ; CHECK-ZMMUL-NEXT: [[COPY1:%[0-9]+]]:_(s32) = COPY $x11 + ; CHECK-ZMMUL-NEXT: [[MUL:%[0-9]+]]:_(s32) = G_MUL [[COPY]], [[COPY1]] + ; CHECK-ZMMUL-NEXT: $x10 = COPY [[MUL]](s32) + ; CHECK-ZMMUL-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-I-LABEL: name: mul_i8 + ; CHECK-I: [[COPY:%[0-9]+]]:_(s32) = COPY $x10 + ; CHECK-I-NEXT: [[COPY1:%[0-9]+]]:_(s32) = COPY $x11 + ; CHECK-I-NEXT: $x10 = COPY [[COPY]](s32) + ; CHECK-I-NEXT: $x11 = COPY [[COPY1]](s32) + ; CHECK-I-NEXT: PseudoCALL target-flags(riscv-call) &__mulsi3, implicit-def $x1, implicit $x10, implicit $x11, implicit-def $x10 + ; CHECK-I-NEXT: [[COPY2:%[0-9]+]]:_(s32) = COPY $x10 + ; CHECK-I-NEXT: $x10 = COPY [[COPY2]](s32) + ; CHECK-I-NEXT: PseudoRET implicit $x10 + ; + ; CHECK-M-LABEL: name: mul_i8 + ; CHECK-M: [[COPY:%[0-9]+]]:_(s32) = COPY $x10 + ; CHECK-M-NEXT: [[COPY1:%[0-9]+]]:_(s32) = COPY $x11 + ; CHECK-M-NEXT: [[MUL:%[0-9]+]]:_(s32) = G_MUL [[COPY]], [[COPY1]] + ; CHECK-M-NEXT: $x10 = COPY [[MUL]](s32) + ; CHECK-M-NEXT: PseudoRET implicit $x10 + ; + ; CHECK-ZMMUL-LABEL: name: mul_i8 + ; CHECK-ZMMUL: [[COPY:%[0-9]+]]:_(s32) = COPY $x10 + ; CHECK-ZMMUL-NEXT: [[COPY1:%[0-9]+]]:_(s32) = COPY $x11 + ; CHECK-ZMMUL-NEXT: [[MUL:%[0-9]+]]:_(s32) = G_MUL [[COPY]], [[COPY1]] + ; CHECK-ZMMUL-NEXT: $x10 = COPY [[MUL]](s32) + ; CHECK-ZMMUL-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-I-LABEL: name: mul_i16 + ; CHECK-I: [[COPY:%[0-9]+]]:_(s32) = COPY $x10 + ; CHECK-I-NEXT: [[COPY1:%[0-9]+]]:_(s32) = COPY $x11 + ; CHECK-I-NEXT: $x10 = COPY [[COPY]](s32) + ; CHECK-I-NEXT: $x11 = COPY [[COPY1]](s32) + ; CHECK-I-NEXT: PseudoCALL target-flags(riscv-call) &__mulsi3, implicit-def $x1, implicit $x10, implicit $x11, implicit-def $x10 + ; CHECK-I-NEXT: [[COPY2:%[0-9]+]]:_(s32) = COPY $x10 + ; CHECK-I-NEXT: $x10 = COPY [[COPY2]](s32) + ; CHECK-I-NEXT: PseudoRET implicit $x10 + ; + ; CHECK-M-LABEL: name: mul_i16 + ; CHECK-M: [[COPY:%[0-9]+]]:_(s32) = COPY $x10 + ; CHECK-M-NEXT: [[COPY1:%[0-9]+]]:_(s32) = COPY $x11 + ; CHECK-M-NEXT: [[MUL:%[0-9]+]]:_(s32) = G_MUL [[COPY]], [[COPY1]] + ; CHECK-M-NEXT: $x10 = COPY [[MUL]](s32) + ; CHECK-M-NEXT: PseudoRET implicit $x10 + ; + ; CHECK-ZMMUL-LABEL: name: mul_i16 + ; CHECK-ZMMUL: [[COPY:%[0-9]+]]:_(s32) = COPY $x10 + ; CHECK-ZMMUL-NEXT: [[COPY1:%[0-9]+]]:_(s32) = COPY $x11 + ; CHECK-ZMMUL-NEXT: [[MUL:%[0-9]+]]:_(s32) = G_MUL [[COPY]], [[COPY1]] + ; CHECK-ZMMUL-NEXT: $x10 = COPY [[MUL]](s32) + ; CHECK-ZMMUL-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-I-LABEL: name: mul_i32 + ; CHECK-I: [[COPY:%[0-9]+]]:_(s32) = COPY $x10 + ; CHECK-I-NEXT: [[COPY1:%[0-9]+]]:_(s32) = COPY $x11 + ; CHECK-I-NEXT: $x10 = COPY [[COPY]](s32) + ; CHECK-I-NEXT: $x11 = COPY [[COPY1]](s32) + ; CHECK-I-NEXT: PseudoCALL target-flags(riscv-call) &__mulsi3, implicit-def $x1, implicit $x10, implicit $x11, implicit-def $x10 + ; CHECK-I-NEXT: [[COPY2:%[0-9]+]]:_(s32) = COPY $x10 + ; CHECK-I-NEXT: $x10 = COPY [[COPY2]](s32) + ; CHECK-I-NEXT: PseudoRET implicit $x10 + ; + ; CHECK-M-LABEL: name: mul_i32 + ; CHECK-M: [[COPY:%[0-9]+]]:_(s32) = COPY $x10 + ; CHECK-M-NEXT: [[COPY1:%[0-9]+]]:_(s32) = COPY $x11 + ; CHECK-M-NEXT: [[MUL:%[0-9]+]]:_(s32) = G_MUL [[COPY]], [[COPY1]] + ; CHECK-M-NEXT: $x10 = COPY [[MUL]](s32) + ; CHECK-M-NEXT: PseudoRET implicit $x10 + ; + ; CHECK-ZMMUL-LABEL: name: mul_i32 + ; CHECK-ZMMUL: [[COPY:%[0-9]+]]:_(s32) = COPY $x10 + ; CHECK-ZMMUL-NEXT: [[COPY1:%[0-9]+]]:_(s32) = COPY $x11 + ; CHECK-ZMMUL-NEXT: [[MUL:%[0-9]+]]:_(s32) = G_MUL [[COPY]], [[COPY1]] + ; CHECK-ZMMUL-NEXT: $x10 = COPY [[MUL]](s32) + ; CHECK-ZMMUL-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_i48 +body: | + bb.0.entry: + ; CHECK-I-LABEL: name: mul_i48 + ; CHECK-I: %xhi:_(s32) = COPY $x10 + ; CHECK-I-NEXT: %xlo:_(s32) = COPY $x11 + ; CHECK-I-NEXT: %yhi:_(s32) = COPY $x12 + ; CHECK-I-NEXT: %ylo:_(s32) = COPY $x13 + ; CHECK-I-NEXT: $x10 = COPY %xhi(s32) + ; CHECK-I-NEXT: $x11 = COPY %yhi(s32) + ; CHECK-I-NEXT: PseudoCALL target-flags(riscv-call) &__mulsi3, implicit-def $x1, implicit $x10, implicit $x11, implicit-def $x10 + ; CHECK-I-NEXT: [[COPY:%[0-9]+]]:_(s32) = COPY $x10 + ; CHECK-I-NEXT: $x10 = COPY %xlo(s32) + ; CHECK-I-NEXT: $x11 = COPY %yhi(s32) + ; CHECK-I-NEXT: PseudoCALL target-flags(riscv-call) &__mulsi3, implicit-def $x1, implicit $x10, implicit $x11, implicit-def $x10 + ; CHECK-I-NEXT: [[COPY1:%[0-9]+]]:_(s32) = COPY $x10 + ; CHECK-I-NEXT: $x10 = COPY %xhi(s32) + ; CHECK-I-NEXT: $x11 = COPY %ylo(s32) + ; CHECK-I-NEXT: PseudoCALL target-flags(riscv-call) &__mulsi3, implicit-def $x1, implicit $x10, implicit $x11, implicit-def $x10 + ; CHECK-I-NEXT: [[COPY2:%[0-9]+]]:_(s32) = COPY $x10 + ; CHECK-I-NEXT: [[UMULH:%[0-9]+]]:_(s32) = G_UMULH %xhi, %yhi + ; CHECK-I-NEXT: [[ADD:%[0-9]+]]:_(s32) = G_ADD [[COPY1]], [[COPY2]] + ; CHECK-I-NEXT: [[ADD1:%[0-9]+]]:_(s32) = G_ADD [[ADD]], [[UMULH]] + ; CHECK-I-NEXT: $x10 = COPY [[COPY]](s32) + ; CHECK-I-NEXT: $x11 = COPY [[ADD1]](s32) + ; CHECK-I-NEXT: PseudoRET implicit $x10, implicit $x11 + ; + ; CHECK-M-LABEL: name: mul_i48 + ; CHECK-M: %xhi:_(s32) = COPY $x10 + ; CHECK-M-NEXT: %xlo:_(s32) = COPY $x11 + ; CHECK-M-NEXT: %yhi:_(s32) = COPY $x12 + ; CHECK-M-NEXT: %ylo:_(s32) = COPY $x13 + ; CHECK-M-NEXT: [[MUL:%[0-9]+]]:_(s32) = G_MUL %xhi, %yhi + ; CHECK-M-NEXT: [[MUL1:%[0-9]+]]:_(s32) = G_MUL %xlo, %yhi + ; CHECK-M-NEXT: [[MUL2:%[0-9]+]]:_(s32) = G_MUL %xhi, %ylo + ; CHECK-M-NEXT: [[UMULH:%[0-9]+]]:_(s32) = G_UMULH %xhi, %yhi + ; CHECK-M-NEXT: [[ADD:%[0-9]+]]:_(s32) = G_ADD [[MUL1]], [[MUL2]] + ; CHECK-M-NEXT: [[ADD1:%[0-9]+]]:_(s32) = G_ADD [[ADD]], [[UMULH]] + ; CHECK-M-NEXT: $x10 = COPY [[MUL]](s32) + ; CHECK-M-NEXT: $x11 = COPY [[ADD1]](s32) + ; CHECK-M-NEXT: PseudoRET implicit $x10, implicit $x11 + ; + ; CHECK-ZMMUL-LABEL: name: mul_i48 + ; CHECK-ZMMUL: %xhi:_(s32) = COPY $x10 + ; CHECK-ZMMUL-NEXT: %xlo:_(s32) = COPY $x11 + ; CHECK-ZMMUL-NEXT: %yhi:_(s32) = COPY $x12 + ; CHECK-ZMMUL-NEXT: %ylo:_(s32) = COPY $x13 + ; CHECK-ZMMUL-NEXT: [[MUL:%[0-9]+]]:_(s32) = G_MUL %xhi, %yhi + ; CHECK-ZMMUL-NEXT: [[MUL1:%[0-9]+]]:_(s32) = G_MUL %xlo, %yhi + ; CHECK-ZMMUL-NEXT: [[MUL2:%[0-9]+]]:_(s32) = G_MUL %xhi, %ylo + ; CHECK-ZMMUL-NEXT: [[UMULH:%[0-9]+]]:_(s32) = G_UMULH %xhi, %yhi + ; CHECK-ZMMUL-NEXT: [[ADD:%[0-9]+]]:_(s32) = G_ADD [[MUL1]], [[MUL2]] + ; CHECK-ZMMUL-NEXT: [[ADD1:%[0-9]+]]:_(s32) = G_ADD [[ADD]], [[UMULH]] + ; CHECK-ZMMUL-NEXT: $x10 = COPY [[MUL]](s32) + ; CHECK-ZMMUL-NEXT: $x11 = COPY [[ADD1]](s32) + ; CHECK-ZMMUL-NEXT: PseudoRET implicit $x10, implicit $x11 + %xhi:_(s32) = COPY $x10 + %xlo:_(s32) = COPY $x11 + %yhi:_(s32) = COPY $x12 + %ylo:_(s32) = COPY $x13 + %x0:_(s64) = G_MERGE_VALUES %xhi(s32), %xlo(s32) + %y0:_(s64) = G_MERGE_VALUES %yhi(s32), %ylo(s32) + %x:_(s48) = G_TRUNC %x0(s64) + %y:_(s48) = G_TRUNC %y0(s64) + %z:_(s48) = G_MUL %x, %y + %z0:_(s64) = G_ANYEXT %z(s48) + %zhi:_(s32), %zlo:_(s32) = G_UNMERGE_VALUES %z0(s64) + $x10 = COPY %zhi(s32) + $x11 = COPY %zlo(s32) + PseudoRET implicit $x10, implicit $x11 + +... +--- +name: mul_i64 +body: | + bb.0.entry: + ; CHECK-I-LABEL: name: mul_i64 + ; CHECK-I: %hi1:_(s32) = COPY $x10 + ; CHECK-I-NEXT: %lo1:_(s32) = COPY $x11 + ; CHECK-I-NEXT: %hi2:_(s32) = COPY $x12 + ; CHECK-I-NEXT: %lo2:_(s32) = COPY $x13 + ; CHECK-I-NEXT: $x10 = COPY %hi1(s32) + ; CHECK-I-NEXT: $x11 = COPY %hi2(s32) + ; CHECK-I-NEXT: PseudoCALL target-flags(riscv-call) &__mulsi3, implicit-def $x1, implicit $x10, implicit $x11, implicit-def $x10 + ; CHECK-I-NEXT: [[COPY:%[0-9]+]]:_(s32) = COPY $x10 + ; CHECK-I-NEXT: $x10 = COPY %lo1(s32) + ; CHECK-I-NEXT: $x11 = COPY %hi2(s32) + ; CHECK-I-NEXT: PseudoCALL target-flags(riscv-call) &__mulsi3, implicit-def $x1, implicit $x10, implicit $x11, implicit-def $x10 + ; CHECK-I-NEXT: [[COPY1:%[0-9]+]]:_(s32) = COPY $x10 + ; CHECK-I-NEXT: $x10 = COPY %hi1(s32) + ; CHECK-I-NEXT: $x11 = COPY %lo2(s32) + ; CHECK-I-NEXT: PseudoCALL target-flags(riscv-call) &__mulsi3, implicit-def $x1, implicit $x10, implicit $x11, implicit-def $x10 + ; CHECK-I-NEXT: [[COPY2:%[0-9]+]]:_(s32) = COPY $x10 + ; CHECK-I-NEXT: [[UMULH:%[0-9]+]]:_(s32) = G_UMULH %hi1, %hi2 + ; CHECK-I-NEXT: [[ADD:%[0-9]+]]:_(s32) = G_ADD [[COPY1]], [[COPY2]] + ; CHECK-I-NEXT: [[ADD1:%[0-9]+]]:_(s32) = G_ADD [[ADD]], [[UMULH]] + ; CHECK-I-NEXT: $x10 = COPY [[COPY]](s32) + ; CHECK-I-NEXT: $x11 = COPY [[ADD1]](s32) + ; CHECK-I-NEXT: PseudoRET implicit $x10, implicit $x11 + ; + ; CHECK-M-LABEL: name: mul_i64 + ; CHECK-M: %hi1:_(s32) = COPY $x10 + ; CHECK-M-NEXT: %lo1:_(s32) = COPY $x11 + ; CHECK-M-NEXT: %hi2:_(s32) = COPY $x12 + ; CHECK-M-NEXT: %lo2:_(s32) = COPY $x13 + ; CHECK-M-NEXT: [[MUL:%[0-9]+]]:_(s32) = G_MUL %hi1, %hi2 + ; CHECK-M-NEXT: [[MUL1:%[0-9]+]]:_(s32) = G_MUL %lo1, %hi2 + ; CHECK-M-NEXT: [[MUL2:%[0-9]+]]:_(s32) = G_MUL %hi1, %lo2 + ; CHECK-M-NEXT: [[UMULH:%[0-9]+]]:_(s32) = G_UMULH %hi1, %hi2 + ; CHECK-M-NEXT: [[ADD:%[0-9]+]]:_(s32) = G_ADD [[MUL1]], [[MUL2]] + ; CHECK-M-NEXT: [[ADD1:%[0-9]+]]:_(s32) = G_ADD [[ADD]], [[UMULH]] + ; CHECK-M-NEXT: $x10 = COPY [[MUL]](s32) + ; CHECK-M-NEXT: $x11 = COPY [[ADD1]](s32) + ; CHECK-M-NEXT: PseudoRET implicit $x10, implicit $x11 + ; + ; CHECK-ZMMUL-LABEL: name: mul_i64 + ; CHECK-ZMMUL: %hi1:_(s32) = COPY $x10 + ; CHECK-ZMMUL-NEXT: %lo1:_(s32) = COPY $x11 + ; CHECK-ZMMUL-NEXT: %hi2:_(s32) = COPY $x12 + ; CHECK-ZMMUL-NEXT: %lo2:_(s32) = COPY $x13 + ; CHECK-ZMMUL-NEXT: [[MUL:%[0-9]+]]:_(s32) = G_MUL %hi1, %hi2 + ; CHECK-ZMMUL-NEXT: [[MUL1:%[0-9]+]]:_(s32) = G_MUL %lo1, %hi2 + ; CHECK-ZMMUL-NEXT: [[MUL2:%[0-9]+]]:_(s32) = G_MUL %hi1, %lo2 + ; CHECK-ZMMUL-NEXT: [[UMULH:%[0-9]+]]:_(s32) = G_UMULH %hi1, %hi2 + ; CHECK-ZMMUL-NEXT: [[ADD:%[0-9]+]]:_(s32) = G_ADD [[MUL1]], [[MUL2]] + ; CHECK-ZMMUL-NEXT: [[ADD1:%[0-9]+]]:_(s32) = G_ADD [[ADD]], [[UMULH]] + ; CHECK-ZMMUL-NEXT: $x10 = COPY [[MUL]](s32) + ; CHECK-ZMMUL-NEXT: $x11 = COPY [[ADD1]](s32) + ; CHECK-ZMMUL-NEXT: PseudoRET implicit $x10, implicit $x11 + %hi1:_(s32) = COPY $x10 + %lo1:_(s32) = COPY $x11 + %hi2:_(s32) = COPY $x12 + %lo2:_(s32) = COPY $x13 + %x1:_(s64) = G_MERGE_VALUES %hi1(s32), %lo1(s32) + %x2:_(s64) = G_MERGE_VALUES %hi2(s32), %lo2(s32) + %y:_(s64) = G_MUL %x1, %x2 + %hiy:_(s32), %loy:_(s32) = G_UNMERGE_VALUES %y(s64) + $x10 = COPY %hiy(s32) + $x11 = COPY %loy(s32) + PseudoRET implicit $x10, implicit $x11 + +... +--- +name: mul_i96 +body: | + bb.0.entry: + ; CHECK-I-LABEL: name: mul_i96 + ; CHECK-I: %hi1:_(s32) = COPY $x10 + ; CHECK-I-NEXT: %mid1:_(s32) = COPY $x11 + ; CHECK-I-NEXT: %lo1:_(s32) = COPY $x12 + ; CHECK-I-NEXT: %hi2:_(s32) = COPY $x13 + ; CHECK-I-NEXT: %mid2:_(s32) = COPY $x14 + ; CHECK-I-NEXT: %lo2:_(s32) = COPY $x15 + ; CHECK-I-NEXT: [[DEF:%[0-9]+]]:_(s32) = G_IMPLICIT_DEF + ; CHECK-I-NEXT: [[DEF1:%[0-9]+]]:_(s32) = G_IMPLICIT_DEF + ; CHECK-I-NEXT: $x10 = COPY %hi1(s32) + ; CHECK-I-NEXT: $x11 = COPY %hi2(s32) + ; CHECK-I-NEXT: PseudoCALL target-flags(riscv-call) &__mulsi3, implicit-def $x1, implicit $x10, implicit $x11, implicit-def $x10 + ; CHECK-I-NEXT: [[COPY:%[0-9]+]]:_(s32) = COPY $x10 + ; CHECK-I-NEXT: $x10 = COPY %mid1(s32) + ; CHECK-I-NEXT: $x11 = COPY %hi2(s32) + ; CHECK-I-NEXT: PseudoCALL target-flags(riscv-call) &__mulsi3, implicit-def $x1, implicit $x10, implicit $x11, implicit-def $x10 + ; CHECK-I-NEXT: [[COPY1:%[0-9]+]]:_(s32) = COPY $x10 + ; CHECK-I-NEXT: $x10 = COPY %hi1(s32) + ; CHECK-I-NEXT: $x11 = COPY %mid2(s32) + ; CHECK-I-NEXT: PseudoCALL target-flags(riscv-call) &__mulsi3, implicit-def $x1, implicit $x10, implicit $x11, implicit-def $x10 + ; CHECK-I-NEXT: [[COPY2:%[0-9]+]]:_(s32) = COPY $x10 + ; CHECK-I-NEXT: [[UMULH:%[0-9]+]]:_(s32) = G_UMULH %hi1, %hi2 + ; CHECK-I-NEXT: [[UADDO:%[0-9]+]]:_(s32), [[UADDO1:%[0-9]+]]:_(s32) = G_UADDO [[COPY1]], [[COPY2]] + ; CHECK-I-NEXT: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 1 + ; CHECK-I-NEXT: [[AND:%[0-9]+]]:_(s32) = G_AND [[UADDO1]], [[C]] + ; CHECK-I-NEXT: [[UADDO2:%[0-9]+]]:_(s32), [[UADDO3:%[0-9]+]]:_(s32) = G_UADDO [[UADDO]], [[UMULH]] + ; CHECK-I-NEXT: [[C1:%[0-9]+]]:_(s32) = G_CONSTANT i32 1 + ; CHECK-I-NEXT: [[AND1:%[0-9]+]]:_(s32) = G_AND [[UADDO3]], [[C1]] + ; CHECK-I-NEXT: [[ADD:%[0-9]+]]:_(s32) = G_ADD [[AND]], [[AND1]] + ; CHECK-I-NEXT: $x10 = COPY %lo1(s32) + ; CHECK-I-NEXT: $x11 = COPY %hi2(s32) + ; CHECK-I-NEXT: PseudoCALL target-flags(riscv-call) &__mulsi3, implicit-def $x1, implicit $x10, implicit $x11, implicit-def $x10 + ; CHECK-I-NEXT: [[COPY3:%[0-9]+]]:_(s32) = COPY $x10 + ; CHECK-I-NEXT: $x10 = COPY %mid1(s32) + ; CHECK-I-NEXT: $x11 = COPY %mid2(s32) + ; CHECK-I-NEXT: PseudoCALL target-flags(riscv-call) &__mulsi3, implicit-def $x1, implicit $x10, implicit $x11, implicit-def $x10 + ; CHECK-I-NEXT: [[COPY4:%[0-9]+]]:_(s32) = COPY $x10 + ; CHECK-I-NEXT: $x10 = COPY %hi1(s32) + ; CHECK-I-NEXT: $x11 = COPY %lo2(s32) + ; CHECK-I-NEXT: PseudoCALL target-flags(riscv-call) &__mulsi3, implicit-def $x1, implicit $x10, implicit $x11, implicit-def $x10 + ; CHECK-I-NEXT: [[COPY5:%[0-9]+]]:_(s32) = COPY $x10 + ; CHECK-I-NEXT: [[UMULH1:%[0-9]+]]:_(s32) = G_UMULH %mid1, %hi2 + ; CHECK-I-NEXT: [[UMULH2:%[0-9]+]]:_(s32) = G_UMULH %hi1, %mid2 + ; CHECK-I-NEXT: [[UADDO4:%[0-9]+]]:_(s32), [[UADDO5:%[0-9]+]]:_(s32) = G_UADDO [[COPY3]], [[COPY4]] + ; CHECK-I-NEXT: [[UADDO6:%[0-9]+]]:_(s32), [[UADDO7:%[0-9]+]]:_(s32) = G_UADDO [[UADDO4]], [[COPY5]] + ; CHECK-I-NEXT: [[UADDO8:%[0-9]+]]:_(s32), [[UADDO9:%[0-9]+]]:_(s32) = G_UADDO [[UADDO6]], [[UMULH1]] + ; CHECK-I-NEXT: [[UADDO10:%[0-9]+]]:_(s32), [[UADDO11:%[0-9]+]]:_(s32) = G_UADDO [[UADDO8]], [[UMULH2]] + ; CHECK-I-NEXT: [[UADDO12:%[0-9]+]]:_(s32), [[UADDO13:%[0-9]+]]:_(s32) = G_UADDO [[UADDO10]], [[ADD]] + ; CHECK-I-NEXT: $x10 = COPY [[DEF]](s32) + ; CHECK-I-NEXT: $x11 = COPY %hi2(s32) + ; CHECK-I-NEXT: PseudoCALL target-flags(riscv-call) &__mulsi3, implicit-def $x1, implicit $x10, implicit $x11, implicit-def $x10 + ; CHECK-I-NEXT: $x10 = COPY %lo1(s32) + ; CHECK-I-NEXT: $x11 = COPY %mid2(s32) + ; CHECK-I-NEXT: PseudoCALL target-flags(riscv-call) &__mulsi3, implicit-def $x1, implicit $x10, implicit $x11, implicit-def $x10 + ; CHECK-I-NEXT: $x10 = COPY %mid1(s32) + ; CHECK-I-NEXT: $x11 = COPY %lo2(s32) + ; CHECK-I-NEXT: PseudoCALL target-flags(riscv-call) &__mulsi3, implicit-def $x1, implicit $x10, implicit $x11, implicit-def $x10 + ; CHECK-I-NEXT: $x10 = COPY %hi1(s32) + ; CHECK-I-NEXT: $x11 = COPY [[DEF1]](s32) + ; CHECK-I-NEXT: PseudoCALL target-flags(riscv-call) &__mulsi3, implicit-def $x1, implicit $x10, implicit $x11, implicit-def $x10 + ; CHECK-I-NEXT: $x10 = COPY [[COPY]](s32) + ; CHECK-I-NEXT: $x11 = COPY [[UADDO2]](s32) + ; CHECK-I-NEXT: $x12 = COPY [[UADDO12]](s32) + ; CHECK-I-NEXT: PseudoRET implicit $x10, implicit $x11, implicit $x12 + ; + ; CHECK-M-LABEL: name: mul_i96 + ; CHECK-M: %hi1:_(s32) = COPY $x10 + ; CHECK-M-NEXT: %mid1:_(s32) = COPY $x11 + ; CHECK-M-NEXT: %lo1:_(s32) = COPY $x12 + ; CHECK-M-NEXT: %hi2:_(s32) = COPY $x13 + ; CHECK-M-NEXT: %mid2:_(s32) = COPY $x14 + ; CHECK-M-NEXT: %lo2:_(s32) = COPY $x15 + ; CHECK-M-NEXT: [[MUL:%[0-9]+]]:_(s32) = G_MUL %hi1, %hi2 + ; CHECK-M-NEXT: [[MUL1:%[0-9]+]]:_(s32) = G_MUL %mid1, %hi2 + ; CHECK-M-NEXT: [[MUL2:%[0-9]+]]:_(s32) = G_MUL %hi1, %mid2 + ; CHECK-M-NEXT: [[UMULH:%[0-9]+]]:_(s32) = G_UMULH %hi1, %hi2 + ; CHECK-M-NEXT: [[UADDO:%[0-9]+]]:_(s32), [[UADDO1:%[0-9]+]]:_(s32) = G_UADDO [[MUL1]], [[MUL2]] + ; CHECK-M-NEXT: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 1 + ; CHECK-M-NEXT: [[AND:%[0-9]+]]:_(s32) = G_AND [[UADDO1]], [[C]] + ; CHECK-M-NEXT: [[UADDO2:%[0-9]+]]:_(s32), [[UADDO3:%[0-9]+]]:_(s32) = G_UADDO [[UADDO]], [[UMULH]] + ; CHECK-M-NEXT: [[C1:%[0-9]+]]:_(s32) = G_CONSTANT i32 1 + ; CHECK-M-NEXT: [[AND1:%[0-9]+]]:_(s32) = G_AND [[UADDO3]], [[C1]] + ; CHECK-M-NEXT: [[ADD:%[0-9]+]]:_(s32) = G_ADD [[AND]], [[AND1]] + ; CHECK-M-NEXT: [[MUL3:%[0-9]+]]:_(s32) = G_MUL %lo1, %hi2 + ; CHECK-M-NEXT: [[MUL4:%[0-9]+]]:_(s32) = G_MUL %mid1, %mid2 + ; CHECK-M-NEXT: [[MUL5:%[0-9]+]]:_(s32) = G_MUL %hi1, %lo2 + ; CHECK-M-NEXT: [[UMULH1:%[0-9]+]]:_(s32) = G_UMULH %mid1, %hi2 + ; CHECK-M-NEXT: [[UMULH2:%[0-9]+]]:_(s32) = G_UMULH %hi1, %mid2 + ; CHECK-M-NEXT: [[UADDO4:%[0-9]+]]:_(s32), [[UADDO5:%[0-9]+]]:_(s32) = G_UADDO [[MUL3]], [[MUL4]] + ; CHECK-M-NEXT: [[UADDO6:%[0-9]+]]:_(s32), [[UADDO7:%[0-9]+]]:_(s32) = G_UADDO [[UADDO4]], [[MUL5]] + ; CHECK-M-NEXT: [[UADDO8:%[0-9]+]]:_(s32), [[UADDO9:%[0-9]+]]:_(s32) = G_UADDO [[UADDO6]], [[UMULH1]] + ; CHECK-M-NEXT: [[UADDO10:%[0-9]+]]:_(s32), [[UADDO11:%[0-9]+]]:_(s32) = G_UADDO [[UADDO8]], [[UMULH2]] + ; CHECK-M-NEXT: [[UADDO12:%[0-9]+]]:_(s32), [[UADDO13:%[0-9]+]]:_(s32) = G_UADDO [[UADDO10]], [[ADD]] + ; CHECK-M-NEXT: $x10 = COPY [[MUL]](s32) + ; CHECK-M-NEXT: $x11 = COPY [[UADDO2]](s32) + ; CHECK-M-NEXT: $x12 = COPY [[UADDO12]](s32) + ; CHECK-M-NEXT: PseudoRET implicit $x10, implicit $x11, implicit $x12 + ; + ; CHECK-ZMMUL-LABEL: name: mul_i96 + ; CHECK-ZMMUL: %hi1:_(s32) = COPY $x10 + ; CHECK-ZMMUL-NEXT: %mid1:_(s32) = COPY $x11 + ; CHECK-ZMMUL-NEXT: %lo1:_(s32) = COPY $x12 + ; CHECK-ZMMUL-NEXT: %hi2:_(s32) = COPY $x13 + ; CHECK-ZMMUL-NEXT: %mid2:_(s32) = COPY $x14 + ; CHECK-ZMMUL-NEXT: %lo2:_(s32) = COPY $x15 + ; CHECK-ZMMUL-NEXT: [[MUL:%[0-9]+]]:_(s32) = G_MUL %hi1, %hi2 + ; CHECK-ZMMUL-NEXT: [[MUL1:%[0-9]+]]:_(s32) = G_MUL %mid1, %hi2 + ; CHECK-ZMMUL-NEXT: [[MUL2:%[0-9]+]]:_(s32) = G_MUL %hi1, %mid2 + ; CHECK-ZMMUL-NEXT: [[UMULH:%[0-9]+]]:_(s32) = G_UMULH %hi1, %hi2 + ; CHECK-ZMMUL-NEXT: [[UADDO:%[0-9]+]]:_(s32), [[UADDO1:%[0-9]+]]:_(s32) = G_UADDO [[MUL1]], [[MUL2]] + ; CHECK-ZMMUL-NEXT: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 1 + ; CHECK-ZMMUL-NEXT: [[AND:%[0-9]+]]:_(s32) = G_AND [[UADDO1]], [[C]] + ; CHECK-ZMMUL-NEXT: [[UADDO2:%[0-9]+]]:_(s32), [[UADDO3:%[0-9]+]]:_(s32) = G_UADDO [[UADDO]], [[UMULH]] + ; CHECK-ZMMUL-NEXT: [[C1:%[0-9]+]]:_(s32) = G_CONSTANT i32 1 + ; CHECK-ZMMUL-NEXT: [[AND1:%[0-9]+]]:_(s32) = G_AND [[UADDO3]], [[C1]] + ; CHECK-ZMMUL-NEXT: [[ADD:%[0-9]+]]:_(s32) = G_ADD [[AND]], [[AND1]] + ; CHECK-ZMMUL-NEXT: [[MUL3:%[0-9]+]]:_(s32) = G_MUL %lo1, %hi2 + ; CHECK-ZMMUL-NEXT: [[MUL4:%[0-9]+]]:_(s32) = G_MUL %mid1, %mid2 + ; CHECK-ZMMUL-NEXT: [[MUL5:%[0-9]+]]:_(s32) = G_MUL %hi1, %lo2 + ; CHECK-ZMMUL-NEXT: [[UMULH1:%[0-9]+]]:_(s32) = G_UMULH %mid1, %hi2 + ; CHECK-ZMMUL-NEXT: [[UMULH2:%[0-9]+]]:_(s32) = G_UMULH %hi1, %mid2 + ; CHECK-ZMMUL-NEXT: [[UADDO4:%[0-9]+]]:_(s32), [[UADDO5:%[0-9]+]]:_(s32) = G_UADDO [[MUL3]], [[MUL4]] + ; CHECK-ZMMUL-NEXT: [[UADDO6:%[0-9]+]]:_(s32), [[UADDO7:%[0-9]+]]:_(s32) = G_UADDO [[UADDO4]], [[MUL5]] + ; CHECK-ZMMUL-NEXT: [[UADDO8:%[0-9]+]]:_(s32), [[UADDO9:%[0-9]+]]:_(s32) = G_UADDO [[UADDO6]], [[UMULH1]] + ; CHECK-ZMMUL-NEXT: [[UADDO10:%[0-9]+]]:_(s32), [[UADDO11:%[0-9]+]]:_(s32) = G_UADDO [[UADDO8]], [[UMULH2]] + ; CHECK-ZMMUL-NEXT: [[UADDO12:%[0-9]+]]:_(s32), [[UADDO13:%[0-9]+]]:_(s32) = G_UADDO [[UADDO10]], [[ADD]] + ; CHECK-ZMMUL-NEXT: $x10 = COPY [[MUL]](s32) + ; CHECK-ZMMUL-NEXT: $x11 = COPY [[UADDO2]](s32) + ; CHECK-ZMMUL-NEXT: $x12 = COPY [[UADDO12]](s32) + ; CHECK-ZMMUL-NEXT: PseudoRET implicit $x10, implicit $x11, implicit $x12 + %hi1:_(s32) = COPY $x10 + %mid1:_(s32) = COPY $x11 + %lo1:_(s32) = COPY $x12 + %hi2:_(s32) = COPY $x13 + %mid2:_(s32) = COPY $x14 + %lo2:_(s32) = COPY $x15 + %x1:_(s96) = G_MERGE_VALUES %hi1(s32), %mid1(s32), %lo1(s32) + %x2:_(s96) = G_MERGE_VALUES %hi2(s32), %mid2(s32), %lo2(s32) + %y:_(s96) = G_MUL %x1, %x2 + %hi:_(s32), %mid:_(s32), %lo:_(s32) = G_UNMERGE_VALUES %y(s96) + $x10 = COPY %hi(s32) + $x11 = COPY %mid(s32) + $x12 = COPY %lo(s32) + PseudoRET implicit $x10, implicit $x11, implicit $x12 + +... diff --git a/llvm/test/CodeGen/RISCV/GlobalISel/legalizer/rv32/legalize-mul.mir b/llvm/test/CodeGen/RISCV/GlobalISel/legalizer/rv32/legalize-mul.mir new file mode 100644 --- /dev/null +++ b/llvm/test/CodeGen/RISCV/GlobalISel/legalizer/rv32/legalize-mul.mir @@ -0,0 +1,92 @@ +# 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: $x10 = COPY [[COPY]](s32) + ; CHECK-NEXT: $x11 = COPY [[COPY1]](s32) + ; CHECK-NEXT: PseudoCALL target-flags(riscv-call) &__mulsi3, implicit-def $x1, implicit $x10, implicit $x11, implicit-def $x10 + ; 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: $x10 = COPY [[COPY]](s32) + ; CHECK-NEXT: $x11 = COPY [[COPY1]](s32) + ; CHECK-NEXT: PseudoCALL target-flags(riscv-call) &__mulsi3, implicit-def $x1, implicit $x10, implicit $x11, implicit-def $x10 + ; 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: $x10 = COPY [[COPY]](s32) + ; CHECK-NEXT: $x11 = COPY [[COPY1]](s32) + ; CHECK-NEXT: PseudoCALL target-flags(riscv-call) &__mulsi3, implicit-def $x1, implicit $x10, implicit $x11, implicit-def $x10 + ; 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: $x10 = COPY [[COPY]](s32) + ; CHECK-NEXT: $x11 = COPY [[COPY1]](s32) + ; CHECK-NEXT: PseudoCALL target-flags(riscv-call) &__mulsi3, implicit-def $x1, implicit $x10, implicit $x11, implicit-def $x10 + ; 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 + +... diff --git a/llvm/test/CodeGen/RISCV/GlobalISel/legalizer/rv64/legalize-mul-ext.mir b/llvm/test/CodeGen/RISCV/GlobalISel/legalizer/rv64/legalize-mul-ext.mir new file mode 100644 --- /dev/null +++ b/llvm/test/CodeGen/RISCV/GlobalISel/legalizer/rv64/legalize-mul-ext.mir @@ -0,0 +1,317 @@ +# NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py +# RUN: llc -mattr=+m -mtriple=riscv64 -run-pass=legalizer %s -o - \ +# RUN: | FileCheck %s -check-prefix=CHECK-IM +# RUN: llc -mattr=+zmmul -mtriple=riscv64 -run-pass=legalizer %s -o - \ +# RUN: | FileCheck %s -check-prefix=CHECK-IZMMUL +--- +name: mul_i8 +body: | + bb.0.entry: + ; CHECK-IM-LABEL: name: mul_i8 + ; CHECK-IM: [[COPY:%[0-9]+]]:_(s64) = COPY $x10 + ; CHECK-IM-NEXT: [[COPY1:%[0-9]+]]:_(s64) = COPY $x11 + ; CHECK-IM-NEXT: [[MUL:%[0-9]+]]:_(s64) = G_MUL [[COPY]], [[COPY1]] + ; CHECK-IM-NEXT: $x10 = COPY [[MUL]](s64) + ; CHECK-IM-NEXT: PseudoRET implicit $x10 + ; + ; CHECK-IZMMUL-LABEL: name: mul_i8 + ; CHECK-IZMMUL: [[COPY:%[0-9]+]]:_(s64) = COPY $x10 + ; CHECK-IZMMUL-NEXT: [[COPY1:%[0-9]+]]:_(s64) = COPY $x11 + ; CHECK-IZMMUL-NEXT: [[MUL:%[0-9]+]]:_(s64) = G_MUL [[COPY]], [[COPY1]] + ; CHECK-IZMMUL-NEXT: $x10 = COPY [[MUL]](s64) + ; CHECK-IZMMUL-NEXT: PseudoRET implicit $x10 + %0:_(s64) = COPY $x10 + %1:_(s64) = COPY $x11 + %2:_(s8) = G_TRUNC %0(s64) + %3:_(s8) = G_TRUNC %1(s64) + %4:_(s8) = G_MUL %2, %3 + %5:_(s64) = G_ANYEXT %4(s8) + $x10 = COPY %5(s64) + PseudoRET implicit $x10 + +... +--- +name: mul_i15 +body: | + bb.0.entry: + ; CHECK-IM-LABEL: name: mul_i15 + ; CHECK-IM: [[COPY:%[0-9]+]]:_(s64) = COPY $x10 + ; CHECK-IM-NEXT: [[COPY1:%[0-9]+]]:_(s64) = COPY $x11 + ; CHECK-IM-NEXT: [[MUL:%[0-9]+]]:_(s64) = G_MUL [[COPY]], [[COPY1]] + ; CHECK-IM-NEXT: $x10 = COPY [[MUL]](s64) + ; CHECK-IM-NEXT: PseudoRET implicit $x10 + ; + ; CHECK-IZMMUL-LABEL: name: mul_i15 + ; CHECK-IZMMUL: [[COPY:%[0-9]+]]:_(s64) = COPY $x10 + ; CHECK-IZMMUL-NEXT: [[COPY1:%[0-9]+]]:_(s64) = COPY $x11 + ; CHECK-IZMMUL-NEXT: [[MUL:%[0-9]+]]:_(s64) = G_MUL [[COPY]], [[COPY1]] + ; CHECK-IZMMUL-NEXT: $x10 = COPY [[MUL]](s64) + ; CHECK-IZMMUL-NEXT: PseudoRET implicit $x10 + %0:_(s64) = COPY $x10 + %1:_(s64) = COPY $x11 + %2:_(s15) = G_TRUNC %0(s64) + %3:_(s15) = G_TRUNC %1(s64) + %4:_(s15) = G_MUL %2, %3 + %5:_(s64) = G_ANYEXT %4(s15) + $x10 = COPY %5(s64) + PseudoRET implicit $x10 + +... +--- +name: mul_i16 +body: | + bb.0.entry: + ; CHECK-IM-LABEL: name: mul_i16 + ; CHECK-IM: [[COPY:%[0-9]+]]:_(s64) = COPY $x10 + ; CHECK-IM-NEXT: [[COPY1:%[0-9]+]]:_(s64) = COPY $x11 + ; CHECK-IM-NEXT: [[MUL:%[0-9]+]]:_(s64) = G_MUL [[COPY]], [[COPY1]] + ; CHECK-IM-NEXT: $x10 = COPY [[MUL]](s64) + ; CHECK-IM-NEXT: PseudoRET implicit $x10 + ; + ; CHECK-IZMMUL-LABEL: name: mul_i16 + ; CHECK-IZMMUL: [[COPY:%[0-9]+]]:_(s64) = COPY $x10 + ; CHECK-IZMMUL-NEXT: [[COPY1:%[0-9]+]]:_(s64) = COPY $x11 + ; CHECK-IZMMUL-NEXT: [[MUL:%[0-9]+]]:_(s64) = G_MUL [[COPY]], [[COPY1]] + ; CHECK-IZMMUL-NEXT: $x10 = COPY [[MUL]](s64) + ; CHECK-IZMMUL-NEXT: PseudoRET implicit $x10 + %0:_(s64) = COPY $x10 + %1:_(s64) = COPY $x11 + %2:_(s16) = G_TRUNC %0(s64) + %3:_(s16) = G_TRUNC %1(s64) + %4:_(s16) = G_MUL %2, %3 + %5:_(s64) = G_ANYEXT %4(s16) + $x10 = COPY %5(s64) + PseudoRET implicit $x10 + +... +--- +name: mul_i32 +body: | + bb.0.entry: + ; CHECK-IM-LABEL: name: mul_i32 + ; CHECK-IM: [[COPY:%[0-9]+]]:_(s64) = COPY $x10 + ; CHECK-IM-NEXT: [[COPY1:%[0-9]+]]:_(s64) = COPY $x11 + ; CHECK-IM-NEXT: [[MUL:%[0-9]+]]:_(s64) = G_MUL [[COPY]], [[COPY1]] + ; CHECK-IM-NEXT: $x10 = COPY [[MUL]](s64) + ; CHECK-IM-NEXT: PseudoRET implicit $x10 + ; + ; CHECK-IZMMUL-LABEL: name: mul_i32 + ; CHECK-IZMMUL: [[COPY:%[0-9]+]]:_(s64) = COPY $x10 + ; CHECK-IZMMUL-NEXT: [[COPY1:%[0-9]+]]:_(s64) = COPY $x11 + ; CHECK-IZMMUL-NEXT: [[MUL:%[0-9]+]]:_(s64) = G_MUL [[COPY]], [[COPY1]] + ; CHECK-IZMMUL-NEXT: $x10 = COPY [[MUL]](s64) + ; CHECK-IZMMUL-NEXT: PseudoRET implicit $x10 + %0:_(s64) = COPY $x10 + %1:_(s64) = COPY $x11 + %2:_(s32) = G_TRUNC %0(s64) + %3:_(s32) = G_TRUNC %1(s64) + %4:_(s32) = G_MUL %2, %3 + %5:_(s64) = G_ANYEXT %4(s32) + $x10 = COPY %5(s64) + PseudoRET implicit $x10 + +... +--- +name: mul_i64 +body: | + bb.0.entry: + ; CHECK-IM-LABEL: name: mul_i64 + ; CHECK-IM: [[COPY:%[0-9]+]]:_(s64) = COPY $x10 + ; CHECK-IM-NEXT: [[COPY1:%[0-9]+]]:_(s64) = COPY $x11 + ; CHECK-IM-NEXT: [[MUL:%[0-9]+]]:_(s64) = G_MUL [[COPY]], [[COPY1]] + ; CHECK-IM-NEXT: $x10 = COPY [[MUL]](s64) + ; CHECK-IM-NEXT: PseudoRET implicit $x10 + ; + ; CHECK-IZMMUL-LABEL: name: mul_i64 + ; CHECK-IZMMUL: [[COPY:%[0-9]+]]:_(s64) = COPY $x10 + ; CHECK-IZMMUL-NEXT: [[COPY1:%[0-9]+]]:_(s64) = COPY $x11 + ; CHECK-IZMMUL-NEXT: [[MUL:%[0-9]+]]:_(s64) = G_MUL [[COPY]], [[COPY1]] + ; CHECK-IZMMUL-NEXT: $x10 = COPY [[MUL]](s64) + ; CHECK-IZMMUL-NEXT: PseudoRET implicit $x10 + %0:_(s64) = COPY $x10 + %1:_(s64) = COPY $x11 + %2:_(s64) = G_MUL %0, %1 + $x10 = COPY %2(s64) + PseudoRET implicit $x10 + +... +--- +name: mul_i72 +body: | + bb.0.entry: + ; CHECK-IM-LABEL: name: mul_i72 + ; CHECK-IM: %xhi:_(s64) = COPY $x10 + ; CHECK-IM-NEXT: %xlo:_(s64) = COPY $x11 + ; CHECK-IM-NEXT: %yhi:_(s64) = COPY $x12 + ; CHECK-IM-NEXT: %ylo:_(s64) = COPY $x13 + ; CHECK-IM-NEXT: [[MUL:%[0-9]+]]:_(s64) = G_MUL %xhi, %yhi + ; CHECK-IM-NEXT: [[MUL1:%[0-9]+]]:_(s64) = G_MUL %xlo, %yhi + ; CHECK-IM-NEXT: [[MUL2:%[0-9]+]]:_(s64) = G_MUL %xhi, %ylo + ; CHECK-IM-NEXT: [[UMULH:%[0-9]+]]:_(s64) = G_UMULH %xhi, %yhi + ; CHECK-IM-NEXT: [[ADD:%[0-9]+]]:_(s64) = G_ADD [[MUL1]], [[MUL2]] + ; CHECK-IM-NEXT: [[ADD1:%[0-9]+]]:_(s64) = G_ADD [[ADD]], [[UMULH]] + ; CHECK-IM-NEXT: $x10 = COPY [[MUL]](s64) + ; CHECK-IM-NEXT: $x11 = COPY [[ADD1]](s64) + ; CHECK-IM-NEXT: PseudoRET implicit $x10, implicit $x11 + ; + ; CHECK-IZMMUL-LABEL: name: mul_i72 + ; CHECK-IZMMUL: %xhi:_(s64) = COPY $x10 + ; CHECK-IZMMUL-NEXT: %xlo:_(s64) = COPY $x11 + ; CHECK-IZMMUL-NEXT: %yhi:_(s64) = COPY $x12 + ; CHECK-IZMMUL-NEXT: %ylo:_(s64) = COPY $x13 + ; CHECK-IZMMUL-NEXT: [[MUL:%[0-9]+]]:_(s64) = G_MUL %xhi, %yhi + ; CHECK-IZMMUL-NEXT: [[MUL1:%[0-9]+]]:_(s64) = G_MUL %xlo, %yhi + ; CHECK-IZMMUL-NEXT: [[MUL2:%[0-9]+]]:_(s64) = G_MUL %xhi, %ylo + ; CHECK-IZMMUL-NEXT: [[UMULH:%[0-9]+]]:_(s64) = G_UMULH %xhi, %yhi + ; CHECK-IZMMUL-NEXT: [[ADD:%[0-9]+]]:_(s64) = G_ADD [[MUL1]], [[MUL2]] + ; CHECK-IZMMUL-NEXT: [[ADD1:%[0-9]+]]:_(s64) = G_ADD [[ADD]], [[UMULH]] + ; CHECK-IZMMUL-NEXT: $x10 = COPY [[MUL]](s64) + ; CHECK-IZMMUL-NEXT: $x11 = COPY [[ADD1]](s64) + ; CHECK-IZMMUL-NEXT: PseudoRET implicit $x10, implicit $x11 + %xhi:_(s64) = COPY $x10 + %xlo:_(s64) = COPY $x11 + %yhi:_(s64) = COPY $x12 + %ylo:_(s64) = COPY $x13 + %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) + %z:_(s72) = G_MUL %x, %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: mul_i128 +body: | + bb.0.entry: + ; CHECK-IM-LABEL: name: mul_i128 + ; CHECK-IM: %hi1:_(s64) = COPY $x10 + ; CHECK-IM-NEXT: %lo1:_(s64) = COPY $x11 + ; CHECK-IM-NEXT: %hi2:_(s64) = COPY $x12 + ; CHECK-IM-NEXT: %lo2:_(s64) = COPY $x13 + ; CHECK-IM-NEXT: [[MUL:%[0-9]+]]:_(s64) = G_MUL %hi1, %hi2 + ; CHECK-IM-NEXT: [[MUL1:%[0-9]+]]:_(s64) = G_MUL %lo1, %hi2 + ; CHECK-IM-NEXT: [[MUL2:%[0-9]+]]:_(s64) = G_MUL %hi1, %lo2 + ; CHECK-IM-NEXT: [[UMULH:%[0-9]+]]:_(s64) = G_UMULH %hi1, %hi2 + ; CHECK-IM-NEXT: [[ADD:%[0-9]+]]:_(s64) = G_ADD [[MUL1]], [[MUL2]] + ; CHECK-IM-NEXT: [[ADD1:%[0-9]+]]:_(s64) = G_ADD [[ADD]], [[UMULH]] + ; CHECK-IM-NEXT: $x10 = COPY [[MUL]](s64) + ; CHECK-IM-NEXT: $x11 = COPY [[ADD1]](s64) + ; CHECK-IM-NEXT: PseudoRET implicit $x10, implicit $x11 + ; + ; CHECK-IZMMUL-LABEL: name: mul_i128 + ; CHECK-IZMMUL: %hi1:_(s64) = COPY $x10 + ; CHECK-IZMMUL-NEXT: %lo1:_(s64) = COPY $x11 + ; CHECK-IZMMUL-NEXT: %hi2:_(s64) = COPY $x12 + ; CHECK-IZMMUL-NEXT: %lo2:_(s64) = COPY $x13 + ; CHECK-IZMMUL-NEXT: [[MUL:%[0-9]+]]:_(s64) = G_MUL %hi1, %hi2 + ; CHECK-IZMMUL-NEXT: [[MUL1:%[0-9]+]]:_(s64) = G_MUL %lo1, %hi2 + ; CHECK-IZMMUL-NEXT: [[MUL2:%[0-9]+]]:_(s64) = G_MUL %hi1, %lo2 + ; CHECK-IZMMUL-NEXT: [[UMULH:%[0-9]+]]:_(s64) = G_UMULH %hi1, %hi2 + ; CHECK-IZMMUL-NEXT: [[ADD:%[0-9]+]]:_(s64) = G_ADD [[MUL1]], [[MUL2]] + ; CHECK-IZMMUL-NEXT: [[ADD1:%[0-9]+]]:_(s64) = G_ADD [[ADD]], [[UMULH]] + ; CHECK-IZMMUL-NEXT: $x10 = COPY [[MUL]](s64) + ; CHECK-IZMMUL-NEXT: $x11 = COPY [[ADD1]](s64) + ; CHECK-IZMMUL-NEXT: PseudoRET implicit $x10, implicit $x11 + %hi1:_(s64) = COPY $x10 + %lo1:_(s64) = COPY $x11 + %hi2:_(s64) = COPY $x12 + %lo2:_(s64) = COPY $x13 + %x1:_(s128) = G_MERGE_VALUES %hi1(s64), %lo1(s64) + %x2:_(s128) = G_MERGE_VALUES %hi2(s64), %lo2(s64) + %y:_(s128) = G_MUL %x1, %x2 + %hiy:_(s64), %loy:_(s64) = G_UNMERGE_VALUES %y(s128) + $x10 = COPY %hiy(s64) + $x11 = COPY %loy(s64) + PseudoRET implicit $x10, implicit $x11 + +... +--- +name: mul_i192 +body: | + bb.0.entry: + ; CHECK-IM-LABEL: name: mul_i192 + ; CHECK-IM: %hi1:_(s64) = COPY $x10 + ; CHECK-IM-NEXT: %mid1:_(s64) = COPY $x11 + ; CHECK-IM-NEXT: %lo1:_(s64) = COPY $x12 + ; CHECK-IM-NEXT: %hi2:_(s64) = COPY $x13 + ; CHECK-IM-NEXT: %mid2:_(s64) = COPY $x14 + ; CHECK-IM-NEXT: %lo2:_(s64) = COPY $x15 + ; CHECK-IM-NEXT: [[MUL:%[0-9]+]]:_(s64) = G_MUL %hi1, %hi2 + ; CHECK-IM-NEXT: [[MUL1:%[0-9]+]]:_(s64) = G_MUL %mid1, %hi2 + ; CHECK-IM-NEXT: [[MUL2:%[0-9]+]]:_(s64) = G_MUL %hi1, %mid2 + ; CHECK-IM-NEXT: [[UMULH:%[0-9]+]]:_(s64) = G_UMULH %hi1, %hi2 + ; CHECK-IM-NEXT: [[UADDO:%[0-9]+]]:_(s64), [[UADDO1:%[0-9]+]]:_(s64) = G_UADDO [[MUL1]], [[MUL2]] + ; CHECK-IM-NEXT: [[C:%[0-9]+]]:_(s64) = G_CONSTANT i64 1 + ; CHECK-IM-NEXT: [[AND:%[0-9]+]]:_(s64) = G_AND [[UADDO1]], [[C]] + ; CHECK-IM-NEXT: [[UADDO2:%[0-9]+]]:_(s64), [[UADDO3:%[0-9]+]]:_(s64) = G_UADDO [[UADDO]], [[UMULH]] + ; CHECK-IM-NEXT: [[C1:%[0-9]+]]:_(s64) = G_CONSTANT i64 1 + ; CHECK-IM-NEXT: [[AND1:%[0-9]+]]:_(s64) = G_AND [[UADDO3]], [[C1]] + ; CHECK-IM-NEXT: [[ADD:%[0-9]+]]:_(s64) = G_ADD [[AND]], [[AND1]] + ; CHECK-IM-NEXT: [[MUL3:%[0-9]+]]:_(s64) = G_MUL %lo1, %hi2 + ; CHECK-IM-NEXT: [[MUL4:%[0-9]+]]:_(s64) = G_MUL %mid1, %mid2 + ; CHECK-IM-NEXT: [[MUL5:%[0-9]+]]:_(s64) = G_MUL %hi1, %lo2 + ; CHECK-IM-NEXT: [[UMULH1:%[0-9]+]]:_(s64) = G_UMULH %mid1, %hi2 + ; CHECK-IM-NEXT: [[UMULH2:%[0-9]+]]:_(s64) = G_UMULH %hi1, %mid2 + ; CHECK-IM-NEXT: [[UADDO4:%[0-9]+]]:_(s64), [[UADDO5:%[0-9]+]]:_(s64) = G_UADDO [[MUL3]], [[MUL4]] + ; CHECK-IM-NEXT: [[UADDO6:%[0-9]+]]:_(s64), [[UADDO7:%[0-9]+]]:_(s64) = G_UADDO [[UADDO4]], [[MUL5]] + ; CHECK-IM-NEXT: [[UADDO8:%[0-9]+]]:_(s64), [[UADDO9:%[0-9]+]]:_(s64) = G_UADDO [[UADDO6]], [[UMULH1]] + ; CHECK-IM-NEXT: [[UADDO10:%[0-9]+]]:_(s64), [[UADDO11:%[0-9]+]]:_(s64) = G_UADDO [[UADDO8]], [[UMULH2]] + ; CHECK-IM-NEXT: [[UADDO12:%[0-9]+]]:_(s64), [[UADDO13:%[0-9]+]]:_(s64) = G_UADDO [[UADDO10]], [[ADD]] + ; CHECK-IM-NEXT: $x10 = COPY [[MUL]](s64) + ; CHECK-IM-NEXT: $x11 = COPY [[UADDO2]](s64) + ; CHECK-IM-NEXT: $x12 = COPY [[UADDO12]](s64) + ; CHECK-IM-NEXT: PseudoRET implicit $x10, implicit $x11, implicit $x12 + ; + ; CHECK-IZMMUL-LABEL: name: mul_i192 + ; CHECK-IZMMUL: %hi1:_(s64) = COPY $x10 + ; CHECK-IZMMUL-NEXT: %mid1:_(s64) = COPY $x11 + ; CHECK-IZMMUL-NEXT: %lo1:_(s64) = COPY $x12 + ; CHECK-IZMMUL-NEXT: %hi2:_(s64) = COPY $x13 + ; CHECK-IZMMUL-NEXT: %mid2:_(s64) = COPY $x14 + ; CHECK-IZMMUL-NEXT: %lo2:_(s64) = COPY $x15 + ; CHECK-IZMMUL-NEXT: [[MUL:%[0-9]+]]:_(s64) = G_MUL %hi1, %hi2 + ; CHECK-IZMMUL-NEXT: [[MUL1:%[0-9]+]]:_(s64) = G_MUL %mid1, %hi2 + ; CHECK-IZMMUL-NEXT: [[MUL2:%[0-9]+]]:_(s64) = G_MUL %hi1, %mid2 + ; CHECK-IZMMUL-NEXT: [[UMULH:%[0-9]+]]:_(s64) = G_UMULH %hi1, %hi2 + ; CHECK-IZMMUL-NEXT: [[UADDO:%[0-9]+]]:_(s64), [[UADDO1:%[0-9]+]]:_(s64) = G_UADDO [[MUL1]], [[MUL2]] + ; CHECK-IZMMUL-NEXT: [[C:%[0-9]+]]:_(s64) = G_CONSTANT i64 1 + ; CHECK-IZMMUL-NEXT: [[AND:%[0-9]+]]:_(s64) = G_AND [[UADDO1]], [[C]] + ; CHECK-IZMMUL-NEXT: [[UADDO2:%[0-9]+]]:_(s64), [[UADDO3:%[0-9]+]]:_(s64) = G_UADDO [[UADDO]], [[UMULH]] + ; CHECK-IZMMUL-NEXT: [[C1:%[0-9]+]]:_(s64) = G_CONSTANT i64 1 + ; CHECK-IZMMUL-NEXT: [[AND1:%[0-9]+]]:_(s64) = G_AND [[UADDO3]], [[C1]] + ; CHECK-IZMMUL-NEXT: [[ADD:%[0-9]+]]:_(s64) = G_ADD [[AND]], [[AND1]] + ; CHECK-IZMMUL-NEXT: [[MUL3:%[0-9]+]]:_(s64) = G_MUL %lo1, %hi2 + ; CHECK-IZMMUL-NEXT: [[MUL4:%[0-9]+]]:_(s64) = G_MUL %mid1, %mid2 + ; CHECK-IZMMUL-NEXT: [[MUL5:%[0-9]+]]:_(s64) = G_MUL %hi1, %lo2 + ; CHECK-IZMMUL-NEXT: [[UMULH1:%[0-9]+]]:_(s64) = G_UMULH %mid1, %hi2 + ; CHECK-IZMMUL-NEXT: [[UMULH2:%[0-9]+]]:_(s64) = G_UMULH %hi1, %mid2 + ; CHECK-IZMMUL-NEXT: [[UADDO4:%[0-9]+]]:_(s64), [[UADDO5:%[0-9]+]]:_(s64) = G_UADDO [[MUL3]], [[MUL4]] + ; CHECK-IZMMUL-NEXT: [[UADDO6:%[0-9]+]]:_(s64), [[UADDO7:%[0-9]+]]:_(s64) = G_UADDO [[UADDO4]], [[MUL5]] + ; CHECK-IZMMUL-NEXT: [[UADDO8:%[0-9]+]]:_(s64), [[UADDO9:%[0-9]+]]:_(s64) = G_UADDO [[UADDO6]], [[UMULH1]] + ; CHECK-IZMMUL-NEXT: [[UADDO10:%[0-9]+]]:_(s64), [[UADDO11:%[0-9]+]]:_(s64) = G_UADDO [[UADDO8]], [[UMULH2]] + ; CHECK-IZMMUL-NEXT: [[UADDO12:%[0-9]+]]:_(s64), [[UADDO13:%[0-9]+]]:_(s64) = G_UADDO [[UADDO10]], [[ADD]] + ; CHECK-IZMMUL-NEXT: $x10 = COPY [[MUL]](s64) + ; CHECK-IZMMUL-NEXT: $x11 = COPY [[UADDO2]](s64) + ; CHECK-IZMMUL-NEXT: $x12 = COPY [[UADDO12]](s64) + ; CHECK-IZMMUL-NEXT: PseudoRET implicit $x10, implicit $x11, implicit $x12 + %hi1:_(s64) = COPY $x10 + %mid1:_(s64) = COPY $x11 + %lo1:_(s64) = COPY $x12 + %hi2:_(s64) = COPY $x13 + %mid2:_(s64) = COPY $x14 + %lo2:_(s64) = COPY $x15 + %x1:_(s192) = G_MERGE_VALUES %hi1(s64), %mid1(s64), %lo1(s64) + %x2:_(s192) = G_MERGE_VALUES %hi2(s64), %mid2(s64), %lo2(s64) + %y:_(s192) = G_MUL %x1, %x2 + %hi:_(s64), %mid:_(s64), %lo:_(s64) = G_UNMERGE_VALUES %y(s192) + $x10 = COPY %hi(s64) + $x11 = COPY %mid(s64) + $x12 = COPY %lo(s64) + PseudoRET implicit $x10, implicit $x11, implicit $x12 + +... diff --git a/llvm/test/CodeGen/RISCV/GlobalISel/legalizer/rv64/legalize-mul.mir b/llvm/test/CodeGen/RISCV/GlobalISel/legalizer/rv64/legalize-mul.mir new file mode 100644 --- /dev/null +++ b/llvm/test/CodeGen/RISCV/GlobalISel/legalizer/rv64/legalize-mul.mir @@ -0,0 +1,115 @@ +# 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: mul_i8 +body: | + bb.0.entry: + ; CHECK-LABEL: name: mul_i8 + ; CHECK: [[COPY:%[0-9]+]]:_(s64) = COPY $x10 + ; CHECK-NEXT: [[COPY1:%[0-9]+]]:_(s64) = COPY $x11 + ; CHECK-NEXT: $x10 = COPY [[COPY]](s64) + ; CHECK-NEXT: $x11 = COPY [[COPY1]](s64) + ; CHECK-NEXT: PseudoCALL target-flags(riscv-call) &__muldi3, implicit-def $x1, implicit $x10, implicit $x11, implicit-def $x10 + ; CHECK-NEXT: [[COPY2:%[0-9]+]]:_(s64) = COPY $x10 + ; CHECK-NEXT: $x10 = COPY [[COPY2]](s64) + ; CHECK-NEXT: PseudoRET implicit $x10 + %0:_(s64) = COPY $x10 + %1:_(s64) = COPY $x11 + %2:_(s8) = G_TRUNC %0(s64) + %3:_(s8) = G_TRUNC %1(s64) + %4:_(s8) = G_MUL %2, %3 + %5:_(s64) = G_ANYEXT %4(s8) + $x10 = COPY %5(s64) + PseudoRET implicit $x10 + +... +--- +name: mul_i15 +body: | + bb.0.entry: + ; CHECK-LABEL: name: mul_i15 + ; CHECK: [[COPY:%[0-9]+]]:_(s64) = COPY $x10 + ; CHECK-NEXT: [[COPY1:%[0-9]+]]:_(s64) = COPY $x11 + ; CHECK-NEXT: $x10 = COPY [[COPY]](s64) + ; CHECK-NEXT: $x11 = COPY [[COPY1]](s64) + ; CHECK-NEXT: PseudoCALL target-flags(riscv-call) &__muldi3, implicit-def $x1, implicit $x10, implicit $x11, implicit-def $x10 + ; CHECK-NEXT: [[COPY2:%[0-9]+]]:_(s64) = COPY $x10 + ; CHECK-NEXT: $x10 = COPY [[COPY2]](s64) + ; CHECK-NEXT: PseudoRET implicit $x10 + %0:_(s64) = COPY $x10 + %1:_(s64) = COPY $x11 + %2:_(s15) = G_TRUNC %0(s64) + %3:_(s15) = G_TRUNC %1(s64) + %4:_(s15) = G_MUL %2, %3 + %5:_(s64) = G_ANYEXT %4(s15) + $x10 = COPY %5(s64) + PseudoRET implicit $x10 + +... +--- +name: mul_i16 +body: | + bb.0.entry: + ; CHECK-LABEL: name: mul_i16 + ; CHECK: [[COPY:%[0-9]+]]:_(s64) = COPY $x10 + ; CHECK-NEXT: [[COPY1:%[0-9]+]]:_(s64) = COPY $x11 + ; CHECK-NEXT: $x10 = COPY [[COPY]](s64) + ; CHECK-NEXT: $x11 = COPY [[COPY1]](s64) + ; CHECK-NEXT: PseudoCALL target-flags(riscv-call) &__muldi3, implicit-def $x1, implicit $x10, implicit $x11, implicit-def $x10 + ; CHECK-NEXT: [[COPY2:%[0-9]+]]:_(s64) = COPY $x10 + ; CHECK-NEXT: $x10 = COPY [[COPY2]](s64) + ; CHECK-NEXT: PseudoRET implicit $x10 + %0:_(s64) = COPY $x10 + %1:_(s64) = COPY $x11 + %2:_(s16) = G_TRUNC %0(s64) + %3:_(s16) = G_TRUNC %1(s64) + %4:_(s16) = G_MUL %2, %3 + %5:_(s64) = G_ANYEXT %4(s16) + $x10 = COPY %5(s64) + PseudoRET implicit $x10 + +... +--- +name: mul_i32 +body: | + bb.0.entry: + ; CHECK-LABEL: name: mul_i32 + ; CHECK: [[COPY:%[0-9]+]]:_(s64) = COPY $x10 + ; CHECK-NEXT: [[COPY1:%[0-9]+]]:_(s64) = COPY $x11 + ; CHECK-NEXT: $x10 = COPY [[COPY]](s64) + ; CHECK-NEXT: $x11 = COPY [[COPY1]](s64) + ; CHECK-NEXT: PseudoCALL target-flags(riscv-call) &__muldi3, implicit-def $x1, implicit $x10, implicit $x11, implicit-def $x10 + ; CHECK-NEXT: [[COPY2:%[0-9]+]]:_(s64) = COPY $x10 + ; CHECK-NEXT: $x10 = COPY [[COPY2]](s64) + ; CHECK-NEXT: PseudoRET implicit $x10 + %0:_(s64) = COPY $x10 + %1:_(s64) = COPY $x11 + %2:_(s32) = G_TRUNC %0(s64) + %3:_(s32) = G_TRUNC %1(s64) + %4:_(s32) = G_MUL %2, %3 + %5:_(s64) = G_ANYEXT %4(s32) + $x10 = COPY %5(s64) + PseudoRET implicit $x10 + +... +--- +name: mul_i64 +body: | + bb.0.entry: + ; CHECK-LABEL: name: mul_i64 + ; CHECK: [[COPY:%[0-9]+]]:_(s64) = COPY $x10 + ; CHECK-NEXT: [[COPY1:%[0-9]+]]:_(s64) = COPY $x11 + ; CHECK-NEXT: $x10 = COPY [[COPY]](s64) + ; CHECK-NEXT: $x11 = COPY [[COPY1]](s64) + ; CHECK-NEXT: PseudoCALL target-flags(riscv-call) &__muldi3, implicit-def $x1, implicit $x10, implicit $x11, implicit-def $x10 + ; CHECK-NEXT: [[COPY2:%[0-9]+]]:_(s64) = COPY $x10 + ; CHECK-NEXT: $x10 = COPY [[COPY2]](s64) + ; CHECK-NEXT: PseudoRET implicit $x10 + %0:_(s64) = COPY $x10 + %1:_(s64) = COPY $x11 + %2:_(s64) = G_MUL %0, %1 + $x10 = COPY %2(s64) + PseudoRET implicit $x10 + +...