1 # NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
2 # RUN: llc -mtriple=riscv64 -run-pass=legalizer %s -o - | FileCheck %s --check-prefixes=RV64I
3 # RUN: llc -mtriple=riscv64 -mattr=+zbb -run-pass=legalizer %s -o - \
4 # RUN: | FileCheck %s --check-prefixes=RV64ZBB
10 ; RV64I-LABEL: name: smax_i8
11 ; RV64I: [[COPY:%[0-9]+]]:_(s64) = COPY $x10
12 ; RV64I-NEXT: [[COPY1:%[0-9]+]]:_(s64) = COPY $x11
13 ; RV64I-NEXT: [[C:%[0-9]+]]:_(s64) = G_CONSTANT i64 56
14 ; RV64I-NEXT: [[SHL:%[0-9]+]]:_(s64) = G_SHL [[COPY]], [[C]](s64)
15 ; RV64I-NEXT: [[ASHR:%[0-9]+]]:_(s64) = G_ASHR [[SHL]], [[C]](s64)
16 ; RV64I-NEXT: [[SHL1:%[0-9]+]]:_(s64) = G_SHL [[COPY1]], [[C]](s64)
17 ; RV64I-NEXT: [[ASHR1:%[0-9]+]]:_(s64) = G_ASHR [[SHL1]], [[C]](s64)
18 ; RV64I-NEXT: [[ICMP:%[0-9]+]]:_(s64) = G_ICMP intpred(sgt), [[ASHR]](s64), [[ASHR1]]
19 ; RV64I-NEXT: [[TRUNC:%[0-9]+]]:_(s32) = G_TRUNC [[COPY]](s64)
20 ; RV64I-NEXT: [[TRUNC1:%[0-9]+]]:_(s32) = G_TRUNC [[COPY1]](s64)
21 ; RV64I-NEXT: [[SELECT:%[0-9]+]]:_(s32) = G_SELECT [[ICMP]](s64), [[TRUNC]], [[TRUNC1]]
22 ; RV64I-NEXT: [[ANYEXT:%[0-9]+]]:_(s64) = G_ANYEXT [[SELECT]](s32)
23 ; RV64I-NEXT: [[SHL2:%[0-9]+]]:_(s64) = G_SHL [[ANYEXT]], [[C]](s64)
24 ; RV64I-NEXT: [[ASHR2:%[0-9]+]]:_(s64) = G_ASHR [[SHL2]], [[C]](s64)
25 ; RV64I-NEXT: $x10 = COPY [[ASHR2]](s64)
26 ; RV64I-NEXT: PseudoRET implicit $x10
28 ; RV64ZBB-LABEL: name: smax_i8
29 ; RV64ZBB: [[COPY:%[0-9]+]]:_(s64) = COPY $x10
30 ; RV64ZBB-NEXT: [[COPY1:%[0-9]+]]:_(s64) = COPY $x11
31 ; RV64ZBB-NEXT: [[SEXT_INREG:%[0-9]+]]:_(s64) = G_SEXT_INREG [[COPY]], 8
32 ; RV64ZBB-NEXT: [[SEXT_INREG1:%[0-9]+]]:_(s64) = G_SEXT_INREG [[COPY1]], 8
33 ; RV64ZBB-NEXT: [[SMAX:%[0-9]+]]:_(s64) = G_SMAX [[SEXT_INREG]], [[SEXT_INREG1]]
34 ; RV64ZBB-NEXT: $x10 = COPY [[SMAX]](s64)
35 ; RV64ZBB-NEXT: PseudoRET implicit $x10
38 %2:_(s8) = G_TRUNC %0(s64)
39 %3:_(s8) = G_TRUNC %1(s64)
40 %4:_(s8) = G_SMAX %2, %3
41 %5:_(s64) = G_SEXT %4(s8)
43 PseudoRET implicit $x10
50 ; RV64I-LABEL: name: smax_i16
51 ; RV64I: [[COPY:%[0-9]+]]:_(s64) = COPY $x10
52 ; RV64I-NEXT: [[COPY1:%[0-9]+]]:_(s64) = COPY $x11
53 ; RV64I-NEXT: [[C:%[0-9]+]]:_(s64) = G_CONSTANT i64 48
54 ; RV64I-NEXT: [[SHL:%[0-9]+]]:_(s64) = G_SHL [[COPY]], [[C]](s64)
55 ; RV64I-NEXT: [[ASHR:%[0-9]+]]:_(s64) = G_ASHR [[SHL]], [[C]](s64)
56 ; RV64I-NEXT: [[SHL1:%[0-9]+]]:_(s64) = G_SHL [[COPY1]], [[C]](s64)
57 ; RV64I-NEXT: [[ASHR1:%[0-9]+]]:_(s64) = G_ASHR [[SHL1]], [[C]](s64)
58 ; RV64I-NEXT: [[ICMP:%[0-9]+]]:_(s64) = G_ICMP intpred(sgt), [[ASHR]](s64), [[ASHR1]]
59 ; RV64I-NEXT: [[TRUNC:%[0-9]+]]:_(s32) = G_TRUNC [[COPY]](s64)
60 ; RV64I-NEXT: [[TRUNC1:%[0-9]+]]:_(s32) = G_TRUNC [[COPY1]](s64)
61 ; RV64I-NEXT: [[SELECT:%[0-9]+]]:_(s32) = G_SELECT [[ICMP]](s64), [[TRUNC]], [[TRUNC1]]
62 ; RV64I-NEXT: [[ANYEXT:%[0-9]+]]:_(s64) = G_ANYEXT [[SELECT]](s32)
63 ; RV64I-NEXT: [[SHL2:%[0-9]+]]:_(s64) = G_SHL [[ANYEXT]], [[C]](s64)
64 ; RV64I-NEXT: [[ASHR2:%[0-9]+]]:_(s64) = G_ASHR [[SHL2]], [[C]](s64)
65 ; RV64I-NEXT: $x10 = COPY [[ASHR2]](s64)
66 ; RV64I-NEXT: PseudoRET implicit $x10
68 ; RV64ZBB-LABEL: name: smax_i16
69 ; RV64ZBB: [[COPY:%[0-9]+]]:_(s64) = COPY $x10
70 ; RV64ZBB-NEXT: [[COPY1:%[0-9]+]]:_(s64) = COPY $x11
71 ; RV64ZBB-NEXT: [[SEXT_INREG:%[0-9]+]]:_(s64) = G_SEXT_INREG [[COPY]], 16
72 ; RV64ZBB-NEXT: [[SEXT_INREG1:%[0-9]+]]:_(s64) = G_SEXT_INREG [[COPY1]], 16
73 ; RV64ZBB-NEXT: [[SMAX:%[0-9]+]]:_(s64) = G_SMAX [[SEXT_INREG]], [[SEXT_INREG1]]
74 ; RV64ZBB-NEXT: $x10 = COPY [[SMAX]](s64)
75 ; RV64ZBB-NEXT: PseudoRET implicit $x10
78 %2:_(s16) = G_TRUNC %0(s64)
79 %3:_(s16) = G_TRUNC %1(s64)
80 %4:_(s16) = G_SMAX %2, %3
81 %5:_(s64) = G_SEXT %4(s16)
83 PseudoRET implicit $x10
90 ; RV64I-LABEL: name: smax_i32
91 ; RV64I: [[COPY:%[0-9]+]]:_(s64) = COPY $x10
92 ; RV64I-NEXT: [[COPY1:%[0-9]+]]:_(s64) = COPY $x11
93 ; RV64I-NEXT: [[TRUNC:%[0-9]+]]:_(s32) = G_TRUNC [[COPY]](s64)
94 ; RV64I-NEXT: [[TRUNC1:%[0-9]+]]:_(s32) = G_TRUNC [[COPY1]](s64)
95 ; RV64I-NEXT: [[SEXT_INREG:%[0-9]+]]:_(s64) = G_SEXT_INREG [[COPY]], 32
96 ; RV64I-NEXT: [[SEXT_INREG1:%[0-9]+]]:_(s64) = G_SEXT_INREG [[COPY1]], 32
97 ; RV64I-NEXT: [[ICMP:%[0-9]+]]:_(s64) = G_ICMP intpred(sgt), [[SEXT_INREG]](s64), [[SEXT_INREG1]]
98 ; RV64I-NEXT: [[SELECT:%[0-9]+]]:_(s32) = G_SELECT [[ICMP]](s64), [[TRUNC]], [[TRUNC1]]
99 ; RV64I-NEXT: [[SEXT:%[0-9]+]]:_(s64) = G_SEXT [[SELECT]](s32)
100 ; RV64I-NEXT: $x10 = COPY [[SEXT]](s64)
101 ; RV64I-NEXT: PseudoRET implicit $x10
103 ; RV64ZBB-LABEL: name: smax_i32
104 ; RV64ZBB: [[COPY:%[0-9]+]]:_(s64) = COPY $x10
105 ; RV64ZBB-NEXT: [[COPY1:%[0-9]+]]:_(s64) = COPY $x11
106 ; RV64ZBB-NEXT: [[SEXT_INREG:%[0-9]+]]:_(s64) = G_SEXT_INREG [[COPY]], 32
107 ; RV64ZBB-NEXT: [[SEXT_INREG1:%[0-9]+]]:_(s64) = G_SEXT_INREG [[COPY1]], 32
108 ; RV64ZBB-NEXT: [[SMAX:%[0-9]+]]:_(s64) = G_SMAX [[SEXT_INREG]], [[SEXT_INREG1]]
109 ; RV64ZBB-NEXT: $x10 = COPY [[SMAX]](s64)
110 ; RV64ZBB-NEXT: PseudoRET implicit $x10
111 %0:_(s64) = COPY $x10
112 %1:_(s64) = COPY $x11
113 %2:_(s32) = G_TRUNC %0(s64)
114 %3:_(s32) = G_TRUNC %1(s64)
115 %4:_(s32) = G_SMAX %2, %3
116 %5:_(s64) = G_SEXT %4(s32)
118 PseudoRET implicit $x10
125 ; RV64I-LABEL: name: smax_i64
126 ; RV64I: [[COPY:%[0-9]+]]:_(s64) = COPY $x10
127 ; RV64I-NEXT: [[COPY1:%[0-9]+]]:_(s64) = COPY $x11
128 ; RV64I-NEXT: [[ICMP:%[0-9]+]]:_(s64) = G_ICMP intpred(sgt), [[COPY]](s64), [[COPY1]]
129 ; RV64I-NEXT: [[SELECT:%[0-9]+]]:_(s64) = G_SELECT [[ICMP]](s64), [[COPY]], [[COPY1]]
130 ; RV64I-NEXT: $x10 = COPY [[SELECT]](s64)
131 ; RV64I-NEXT: PseudoRET implicit $x10
133 ; RV64ZBB-LABEL: name: smax_i64
134 ; RV64ZBB: [[COPY:%[0-9]+]]:_(s64) = COPY $x10
135 ; RV64ZBB-NEXT: [[COPY1:%[0-9]+]]:_(s64) = COPY $x11
136 ; RV64ZBB-NEXT: [[SMAX:%[0-9]+]]:_(s64) = G_SMAX [[COPY]], [[COPY1]]
137 ; RV64ZBB-NEXT: $x10 = COPY [[SMAX]](s64)
138 ; RV64ZBB-NEXT: PseudoRET implicit $x10
139 %0:_(s64) = COPY $x10
140 %1:_(s64) = COPY $x11
141 %2:_(s64) = G_SMAX %0, %1
143 PseudoRET implicit $x10