1 # NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
2 # RUN: llc -mtriple=riscv32 -run-pass=legalizer %s -o - | FileCheck %s --check-prefixes=CHECK,RV32I
3 # RUN: llc -mtriple=riscv32 -mattr=+zbb -run-pass=legalizer %s -o - \
4 # RUN: | FileCheck %s --check-prefixes=CHECK,RV32ZBB
10 ; RV32I-LABEL: name: umax_i8
11 ; RV32I: [[COPY:%[0-9]+]]:_(s32) = COPY $x10
12 ; RV32I-NEXT: [[COPY1:%[0-9]+]]:_(s32) = COPY $x11
13 ; RV32I-NEXT: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 255
14 ; RV32I-NEXT: [[AND:%[0-9]+]]:_(s32) = G_AND [[COPY]], [[C]]
15 ; RV32I-NEXT: [[AND1:%[0-9]+]]:_(s32) = G_AND [[COPY1]], [[C]]
16 ; RV32I-NEXT: [[ICMP:%[0-9]+]]:_(s32) = G_ICMP intpred(ugt), [[AND]](s32), [[AND1]]
17 ; RV32I-NEXT: [[SELECT:%[0-9]+]]:_(s32) = G_SELECT [[ICMP]](s32), [[COPY]], [[COPY1]]
18 ; RV32I-NEXT: [[AND2:%[0-9]+]]:_(s32) = G_AND [[SELECT]], [[C]]
19 ; RV32I-NEXT: $x10 = COPY [[AND2]](s32)
20 ; RV32I-NEXT: PseudoRET implicit $x10
22 ; RV32ZBB-LABEL: name: umax_i8
23 ; RV32ZBB: [[COPY:%[0-9]+]]:_(s32) = COPY $x10
24 ; RV32ZBB-NEXT: [[COPY1:%[0-9]+]]:_(s32) = COPY $x11
25 ; RV32ZBB-NEXT: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 255
26 ; RV32ZBB-NEXT: [[AND:%[0-9]+]]:_(s32) = G_AND [[COPY]], [[C]]
27 ; RV32ZBB-NEXT: [[AND1:%[0-9]+]]:_(s32) = G_AND [[COPY1]], [[C]]
28 ; RV32ZBB-NEXT: [[UMAX:%[0-9]+]]:_(s32) = G_UMAX [[AND]], [[AND1]]
29 ; RV32ZBB-NEXT: $x10 = COPY [[UMAX]](s32)
30 ; RV32ZBB-NEXT: PseudoRET implicit $x10
33 %2:_(s8) = G_TRUNC %0(s32)
34 %3:_(s8) = G_TRUNC %1(s32)
35 %4:_(s8) = G_UMAX %2, %3
36 %5:_(s32) = G_ZEXT %4(s8)
38 PseudoRET implicit $x10
45 ; RV32I-LABEL: name: umax_i16
46 ; RV32I: [[COPY:%[0-9]+]]:_(s32) = COPY $x10
47 ; RV32I-NEXT: [[COPY1:%[0-9]+]]:_(s32) = COPY $x11
48 ; RV32I-NEXT: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 65535
49 ; RV32I-NEXT: [[AND:%[0-9]+]]:_(s32) = G_AND [[COPY]], [[C]]
50 ; RV32I-NEXT: [[AND1:%[0-9]+]]:_(s32) = G_AND [[COPY1]], [[C]]
51 ; RV32I-NEXT: [[ICMP:%[0-9]+]]:_(s32) = G_ICMP intpred(ugt), [[AND]](s32), [[AND1]]
52 ; RV32I-NEXT: [[SELECT:%[0-9]+]]:_(s32) = G_SELECT [[ICMP]](s32), [[COPY]], [[COPY1]]
53 ; RV32I-NEXT: [[AND2:%[0-9]+]]:_(s32) = G_AND [[SELECT]], [[C]]
54 ; RV32I-NEXT: $x10 = COPY [[AND2]](s32)
55 ; RV32I-NEXT: PseudoRET implicit $x10
57 ; RV32ZBB-LABEL: name: umax_i16
58 ; RV32ZBB: [[COPY:%[0-9]+]]:_(s32) = COPY $x10
59 ; RV32ZBB-NEXT: [[COPY1:%[0-9]+]]:_(s32) = COPY $x11
60 ; RV32ZBB-NEXT: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 65535
61 ; RV32ZBB-NEXT: [[AND:%[0-9]+]]:_(s32) = G_AND [[COPY]], [[C]]
62 ; RV32ZBB-NEXT: [[AND1:%[0-9]+]]:_(s32) = G_AND [[COPY1]], [[C]]
63 ; RV32ZBB-NEXT: [[UMAX:%[0-9]+]]:_(s32) = G_UMAX [[AND]], [[AND1]]
64 ; RV32ZBB-NEXT: $x10 = COPY [[UMAX]](s32)
65 ; RV32ZBB-NEXT: PseudoRET implicit $x10
68 %2:_(s16) = G_TRUNC %0(s32)
69 %3:_(s16) = G_TRUNC %1(s32)
70 %4:_(s16) = G_UMAX %2, %3
71 %5:_(s32) = G_ZEXT %4(s16)
73 PseudoRET implicit $x10
80 ; RV32I-LABEL: name: umax_i32
81 ; RV32I: [[COPY:%[0-9]+]]:_(s32) = COPY $x10
82 ; RV32I-NEXT: [[COPY1:%[0-9]+]]:_(s32) = COPY $x11
83 ; RV32I-NEXT: [[ICMP:%[0-9]+]]:_(s32) = G_ICMP intpred(ugt), [[COPY]](s32), [[COPY1]]
84 ; RV32I-NEXT: [[SELECT:%[0-9]+]]:_(s32) = G_SELECT [[ICMP]](s32), [[COPY]], [[COPY1]]
85 ; RV32I-NEXT: $x10 = COPY [[SELECT]](s32)
86 ; RV32I-NEXT: PseudoRET implicit $x10
88 ; RV32ZBB-LABEL: name: umax_i32
89 ; RV32ZBB: [[COPY:%[0-9]+]]:_(s32) = COPY $x10
90 ; RV32ZBB-NEXT: [[COPY1:%[0-9]+]]:_(s32) = COPY $x11
91 ; RV32ZBB-NEXT: [[UMAX:%[0-9]+]]:_(s32) = G_UMAX [[COPY]], [[COPY1]]
92 ; RV32ZBB-NEXT: $x10 = COPY [[UMAX]](s32)
93 ; RV32ZBB-NEXT: PseudoRET implicit $x10
96 %2:_(s32) = G_UMAX %0, %1
98 PseudoRET implicit $x10
105 ; CHECK-LABEL: name: umax_i64
106 ; CHECK: [[COPY:%[0-9]+]]:_(s32) = COPY $x10
107 ; CHECK-NEXT: [[COPY1:%[0-9]+]]:_(s32) = COPY $x11
108 ; CHECK-NEXT: [[COPY2:%[0-9]+]]:_(s32) = COPY $x12
109 ; CHECK-NEXT: [[COPY3:%[0-9]+]]:_(s32) = COPY $x13
110 ; CHECK-NEXT: [[ICMP:%[0-9]+]]:_(s32) = G_ICMP intpred(ugt), [[COPY]](s32), [[COPY2]]
111 ; CHECK-NEXT: [[ICMP1:%[0-9]+]]:_(s32) = G_ICMP intpred(ugt), [[COPY1]](s32), [[COPY3]]
112 ; CHECK-NEXT: [[ICMP2:%[0-9]+]]:_(s32) = G_ICMP intpred(eq), [[COPY1]](s32), [[COPY3]]
113 ; CHECK-NEXT: [[SELECT:%[0-9]+]]:_(s32) = G_SELECT [[ICMP2]](s32), [[ICMP]], [[ICMP1]]
114 ; CHECK-NEXT: [[SELECT1:%[0-9]+]]:_(s32) = G_SELECT [[SELECT]](s32), [[COPY]], [[COPY2]]
115 ; CHECK-NEXT: $x10 = COPY [[SELECT1]](s32)
116 ; CHECK-NEXT: PseudoRET implicit $x10
117 %0:_(s32) = COPY $x10
118 %1:_(s32) = COPY $x11
119 %2:_(s32) = COPY $x12
120 %3:_(s32) = COPY $x13
121 %4:_(s64) = G_MERGE_VALUES %0(s32), %1(s32)
122 %5:_(s64) = G_MERGE_VALUES %2(s32), %3(s32)
123 %6:_(s64) = G_UMAX %4, %5
124 %7:_(s32) = G_TRUNC %6(s64)
126 PseudoRET implicit $x10