1 # NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
2 # RUN: llc -mtriple=riscv32 -run-pass=legalizer %s -o - \
8 ; CHECK-LABEL: name: mul_i7
9 ; CHECK: [[COPY:%[0-9]+]]:_(s32) = COPY $x10
10 ; CHECK-NEXT: [[COPY1:%[0-9]+]]:_(s32) = COPY $x11
11 ; CHECK-NEXT: ADJCALLSTACKDOWN 0, 0, implicit-def $x2, implicit $x2
12 ; CHECK-NEXT: $x10 = COPY [[COPY]](s32)
13 ; CHECK-NEXT: $x11 = COPY [[COPY1]](s32)
14 ; CHECK-NEXT: PseudoCALL target-flags(riscv-call) &__mulsi3, csr_ilp32_lp64, implicit-def $x1, implicit $x10, implicit $x11, implicit-def $x10
15 ; CHECK-NEXT: ADJCALLSTACKUP 0, 0, implicit-def $x2, implicit $x2
16 ; CHECK-NEXT: [[COPY2:%[0-9]+]]:_(s32) = COPY $x10
17 ; CHECK-NEXT: $x10 = COPY [[COPY2]](s32)
18 ; CHECK-NEXT: PseudoRET implicit $x10
21 %2:_(s7) = G_TRUNC %0(s32)
22 %3:_(s7) = G_TRUNC %1(s32)
23 %4:_(s7) = G_MUL %2, %3
24 %5:_(s32) = G_ANYEXT %4(s7)
26 PseudoRET implicit $x10
33 ; CHECK-LABEL: name: mul_i8
34 ; CHECK: [[COPY:%[0-9]+]]:_(s32) = COPY $x10
35 ; CHECK-NEXT: [[COPY1:%[0-9]+]]:_(s32) = COPY $x11
36 ; CHECK-NEXT: ADJCALLSTACKDOWN 0, 0, implicit-def $x2, implicit $x2
37 ; CHECK-NEXT: $x10 = COPY [[COPY]](s32)
38 ; CHECK-NEXT: $x11 = COPY [[COPY1]](s32)
39 ; CHECK-NEXT: PseudoCALL target-flags(riscv-call) &__mulsi3, csr_ilp32_lp64, implicit-def $x1, implicit $x10, implicit $x11, implicit-def $x10
40 ; CHECK-NEXT: ADJCALLSTACKUP 0, 0, implicit-def $x2, implicit $x2
41 ; CHECK-NEXT: [[COPY2:%[0-9]+]]:_(s32) = COPY $x10
42 ; CHECK-NEXT: $x10 = COPY [[COPY2]](s32)
43 ; CHECK-NEXT: PseudoRET implicit $x10
46 %2:_(s8) = G_TRUNC %0(s32)
47 %3:_(s8) = G_TRUNC %1(s32)
48 %4:_(s8) = G_MUL %2, %3
49 %5:_(s32) = G_ANYEXT %4(s8)
51 PseudoRET implicit $x10
58 ; CHECK-LABEL: name: mul_i16
59 ; CHECK: [[COPY:%[0-9]+]]:_(s32) = COPY $x10
60 ; CHECK-NEXT: [[COPY1:%[0-9]+]]:_(s32) = COPY $x11
61 ; CHECK-NEXT: ADJCALLSTACKDOWN 0, 0, implicit-def $x2, implicit $x2
62 ; CHECK-NEXT: $x10 = COPY [[COPY]](s32)
63 ; CHECK-NEXT: $x11 = COPY [[COPY1]](s32)
64 ; CHECK-NEXT: PseudoCALL target-flags(riscv-call) &__mulsi3, csr_ilp32_lp64, implicit-def $x1, implicit $x10, implicit $x11, implicit-def $x10
65 ; CHECK-NEXT: ADJCALLSTACKUP 0, 0, implicit-def $x2, implicit $x2
66 ; CHECK-NEXT: [[COPY2:%[0-9]+]]:_(s32) = COPY $x10
67 ; CHECK-NEXT: $x10 = COPY [[COPY2]](s32)
68 ; CHECK-NEXT: PseudoRET implicit $x10
71 %2:_(s16) = G_TRUNC %0(s32)
72 %3:_(s16) = G_TRUNC %1(s32)
73 %4:_(s16) = G_MUL %2, %3
74 %5:_(s32) = G_ANYEXT %4(s16)
76 PseudoRET implicit $x10
83 ; CHECK-LABEL: name: mul_i32
84 ; CHECK: [[COPY:%[0-9]+]]:_(s32) = COPY $x10
85 ; CHECK-NEXT: [[COPY1:%[0-9]+]]:_(s32) = COPY $x11
86 ; CHECK-NEXT: ADJCALLSTACKDOWN 0, 0, implicit-def $x2, implicit $x2
87 ; CHECK-NEXT: $x10 = COPY [[COPY]](s32)
88 ; CHECK-NEXT: $x11 = COPY [[COPY1]](s32)
89 ; CHECK-NEXT: PseudoCALL target-flags(riscv-call) &__mulsi3, csr_ilp32_lp64, implicit-def $x1, implicit $x10, implicit $x11, implicit-def $x10
90 ; CHECK-NEXT: ADJCALLSTACKUP 0, 0, implicit-def $x2, implicit $x2
91 ; CHECK-NEXT: [[COPY2:%[0-9]+]]:_(s32) = COPY $x10
92 ; CHECK-NEXT: $x10 = COPY [[COPY2]](s32)
93 ; CHECK-NEXT: PseudoRET implicit $x10
96 %2:_(s32) = G_MUL %0, %1
98 PseudoRET implicit $x10
105 ; CHECK-LABEL: name: mul_i64
106 ; CHECK: %lo1:_(s32) = COPY $x10
107 ; CHECK-NEXT: %hi1:_(s32) = COPY $x11
108 ; CHECK-NEXT: %lo2:_(s32) = COPY $x12
109 ; CHECK-NEXT: %hi2:_(s32) = COPY $x13
110 ; CHECK-NEXT: ADJCALLSTACKDOWN 0, 0, implicit-def $x2, implicit $x2
111 ; CHECK-NEXT: $x10 = COPY %lo1(s32)
112 ; CHECK-NEXT: $x11 = COPY %hi1(s32)
113 ; CHECK-NEXT: $x12 = COPY %lo2(s32)
114 ; CHECK-NEXT: $x13 = COPY %hi2(s32)
115 ; 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
116 ; CHECK-NEXT: ADJCALLSTACKUP 0, 0, implicit-def $x2, implicit $x2
117 ; CHECK-NEXT: [[COPY:%[0-9]+]]:_(s32) = COPY $x10
118 ; CHECK-NEXT: [[COPY1:%[0-9]+]]:_(s32) = COPY $x11
119 ; CHECK-NEXT: $x10 = COPY [[COPY]](s32)
120 ; CHECK-NEXT: $x11 = COPY [[COPY1]](s32)
121 ; CHECK-NEXT: PseudoRET implicit $x10, implicit $x11
122 %lo1:_(s32) = COPY $x10
123 %hi1:_(s32) = COPY $x11
124 %lo2:_(s32) = COPY $x12
125 %hi2:_(s32) = COPY $x13
126 %x1:_(s64) = G_MERGE_VALUES %lo1(s32), %hi1(s32)
127 %x2:_(s64) = G_MERGE_VALUES %lo2(s32), %hi2(s32)
128 %y:_(s64) = G_MUL %x1, %x2
129 %loy:_(s32), %hiy:_(s32) = G_UNMERGE_VALUES %y(s64)
130 $x10 = COPY %loy(s32)
131 $x11 = COPY %hiy(s32)
132 PseudoRET implicit $x10, implicit $x11
139 ; CHECK-LABEL: name: smulh_i32
140 ; CHECK: [[COPY:%[0-9]+]]:_(s32) = COPY $x10
141 ; CHECK-NEXT: [[COPY1:%[0-9]+]]:_(s32) = COPY $x11
142 ; CHECK-NEXT: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 31
143 ; CHECK-NEXT: [[ASHR:%[0-9]+]]:_(s32) = G_ASHR [[COPY]], [[C]](s32)
144 ; CHECK-NEXT: [[ASHR1:%[0-9]+]]:_(s32) = G_ASHR [[COPY1]], [[C]](s32)
145 ; CHECK-NEXT: ADJCALLSTACKDOWN 0, 0, implicit-def $x2, implicit $x2
146 ; CHECK-NEXT: $x10 = COPY [[COPY]](s32)
147 ; CHECK-NEXT: $x11 = COPY [[ASHR]](s32)
148 ; CHECK-NEXT: $x12 = COPY [[COPY1]](s32)
149 ; CHECK-NEXT: $x13 = COPY [[ASHR1]](s32)
150 ; 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
151 ; CHECK-NEXT: ADJCALLSTACKUP 0, 0, implicit-def $x2, implicit $x2
152 ; CHECK-NEXT: [[COPY2:%[0-9]+]]:_(s32) = COPY $x11
153 ; CHECK-NEXT: $x10 = COPY [[COPY2]](s32)
154 ; CHECK-NEXT: PseudoRET implicit $x10
155 %0:_(s32) = COPY $x10
156 %1:_(s32) = COPY $x11
157 %2:_(s32) = G_SMULH %0, %1
159 PseudoRET implicit $x10