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: smax_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 24
14 ; RV32I-NEXT: [[SHL:%[0-9]+]]:_(s32) = G_SHL [[COPY]], [[C]](s32)
15 ; RV32I-NEXT: [[ASHR:%[0-9]+]]:_(s32) = G_ASHR [[SHL]], [[C]](s32)
16 ; RV32I-NEXT: [[SHL1:%[0-9]+]]:_(s32) = G_SHL [[COPY1]], [[C]](s32)
17 ; RV32I-NEXT: [[ASHR1:%[0-9]+]]:_(s32) = G_ASHR [[SHL1]], [[C]](s32)
18 ; RV32I-NEXT: [[ICMP:%[0-9]+]]:_(s32) = G_ICMP intpred(sgt), [[ASHR]](s32), [[ASHR1]]
19 ; RV32I-NEXT: [[SELECT:%[0-9]+]]:_(s32) = G_SELECT [[ICMP]](s32), [[COPY]], [[COPY1]]
20 ; RV32I-NEXT: [[SHL2:%[0-9]+]]:_(s32) = G_SHL [[SELECT]], [[C]](s32)
21 ; RV32I-NEXT: [[ASHR2:%[0-9]+]]:_(s32) = G_ASHR [[SHL2]], [[C]](s32)
22 ; RV32I-NEXT: $x10 = COPY [[ASHR2]](s32)
23 ; RV32I-NEXT: PseudoRET implicit $x10
25 ; RV32ZBB-LABEL: name: smax_i8
26 ; RV32ZBB: [[COPY:%[0-9]+]]:_(s32) = COPY $x10
27 ; RV32ZBB-NEXT: [[COPY1:%[0-9]+]]:_(s32) = COPY $x11
28 ; RV32ZBB-NEXT: [[SEXT_INREG:%[0-9]+]]:_(s32) = G_SEXT_INREG [[COPY]], 8
29 ; RV32ZBB-NEXT: [[SEXT_INREG1:%[0-9]+]]:_(s32) = G_SEXT_INREG [[COPY1]], 8
30 ; RV32ZBB-NEXT: [[SMAX:%[0-9]+]]:_(s32) = G_SMAX [[SEXT_INREG]], [[SEXT_INREG1]]
31 ; RV32ZBB-NEXT: $x10 = COPY [[SMAX]](s32)
32 ; RV32ZBB-NEXT: PseudoRET implicit $x10
35 %2:_(s8) = G_TRUNC %0(s32)
36 %3:_(s8) = G_TRUNC %1(s32)
37 %4:_(s8) = G_SMAX %2, %3
38 %5:_(s32) = G_SEXT %4(s8)
40 PseudoRET implicit $x10
47 ; RV32I-LABEL: name: smax_i16
48 ; RV32I: [[COPY:%[0-9]+]]:_(s32) = COPY $x10
49 ; RV32I-NEXT: [[COPY1:%[0-9]+]]:_(s32) = COPY $x11
50 ; RV32I-NEXT: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 16
51 ; RV32I-NEXT: [[SHL:%[0-9]+]]:_(s32) = G_SHL [[COPY]], [[C]](s32)
52 ; RV32I-NEXT: [[ASHR:%[0-9]+]]:_(s32) = G_ASHR [[SHL]], [[C]](s32)
53 ; RV32I-NEXT: [[SHL1:%[0-9]+]]:_(s32) = G_SHL [[COPY1]], [[C]](s32)
54 ; RV32I-NEXT: [[ASHR1:%[0-9]+]]:_(s32) = G_ASHR [[SHL1]], [[C]](s32)
55 ; RV32I-NEXT: [[ICMP:%[0-9]+]]:_(s32) = G_ICMP intpred(sgt), [[ASHR]](s32), [[ASHR1]]
56 ; RV32I-NEXT: [[SELECT:%[0-9]+]]:_(s32) = G_SELECT [[ICMP]](s32), [[COPY]], [[COPY1]]
57 ; RV32I-NEXT: [[SHL2:%[0-9]+]]:_(s32) = G_SHL [[SELECT]], [[C]](s32)
58 ; RV32I-NEXT: [[ASHR2:%[0-9]+]]:_(s32) = G_ASHR [[SHL2]], [[C]](s32)
59 ; RV32I-NEXT: $x10 = COPY [[ASHR2]](s32)
60 ; RV32I-NEXT: PseudoRET implicit $x10
62 ; RV32ZBB-LABEL: name: smax_i16
63 ; RV32ZBB: [[COPY:%[0-9]+]]:_(s32) = COPY $x10
64 ; RV32ZBB-NEXT: [[COPY1:%[0-9]+]]:_(s32) = COPY $x11
65 ; RV32ZBB-NEXT: [[SEXT_INREG:%[0-9]+]]:_(s32) = G_SEXT_INREG [[COPY]], 16
66 ; RV32ZBB-NEXT: [[SEXT_INREG1:%[0-9]+]]:_(s32) = G_SEXT_INREG [[COPY1]], 16
67 ; RV32ZBB-NEXT: [[SMAX:%[0-9]+]]:_(s32) = G_SMAX [[SEXT_INREG]], [[SEXT_INREG1]]
68 ; RV32ZBB-NEXT: $x10 = COPY [[SMAX]](s32)
69 ; RV32ZBB-NEXT: PseudoRET implicit $x10
72 %2:_(s16) = G_TRUNC %0(s32)
73 %3:_(s16) = G_TRUNC %1(s32)
74 %4:_(s16) = G_SMAX %2, %3
75 %5:_(s32) = G_SEXT %4(s16)
77 PseudoRET implicit $x10
84 ; RV32I-LABEL: name: smax_i32
85 ; RV32I: [[COPY:%[0-9]+]]:_(s32) = COPY $x10
86 ; RV32I-NEXT: [[COPY1:%[0-9]+]]:_(s32) = COPY $x11
87 ; RV32I-NEXT: [[ICMP:%[0-9]+]]:_(s32) = G_ICMP intpred(sgt), [[COPY]](s32), [[COPY1]]
88 ; RV32I-NEXT: [[SELECT:%[0-9]+]]:_(s32) = G_SELECT [[ICMP]](s32), [[COPY]], [[COPY1]]
89 ; RV32I-NEXT: $x10 = COPY [[SELECT]](s32)
90 ; RV32I-NEXT: PseudoRET implicit $x10
92 ; RV32ZBB-LABEL: name: smax_i32
93 ; RV32ZBB: [[COPY:%[0-9]+]]:_(s32) = COPY $x10
94 ; RV32ZBB-NEXT: [[COPY1:%[0-9]+]]:_(s32) = COPY $x11
95 ; RV32ZBB-NEXT: [[SMAX:%[0-9]+]]:_(s32) = G_SMAX [[COPY]], [[COPY1]]
96 ; RV32ZBB-NEXT: $x10 = COPY [[SMAX]](s32)
97 ; RV32ZBB-NEXT: PseudoRET implicit $x10
100 %2:_(s32) = G_SMAX %0, %1
102 PseudoRET implicit $x10
109 ; CHECK-LABEL: name: smax_i64
110 ; CHECK: [[COPY:%[0-9]+]]:_(s32) = COPY $x10
111 ; CHECK-NEXT: [[COPY1:%[0-9]+]]:_(s32) = COPY $x11
112 ; CHECK-NEXT: [[COPY2:%[0-9]+]]:_(s32) = COPY $x12
113 ; CHECK-NEXT: [[COPY3:%[0-9]+]]:_(s32) = COPY $x13
114 ; CHECK-NEXT: [[ICMP:%[0-9]+]]:_(s32) = G_ICMP intpred(ugt), [[COPY]](s32), [[COPY2]]
115 ; CHECK-NEXT: [[ICMP1:%[0-9]+]]:_(s32) = G_ICMP intpred(sgt), [[COPY1]](s32), [[COPY3]]
116 ; CHECK-NEXT: [[ICMP2:%[0-9]+]]:_(s32) = G_ICMP intpred(eq), [[COPY1]](s32), [[COPY3]]
117 ; CHECK-NEXT: [[SELECT:%[0-9]+]]:_(s32) = G_SELECT [[ICMP2]](s32), [[ICMP]], [[ICMP1]]
118 ; CHECK-NEXT: [[SELECT1:%[0-9]+]]:_(s32) = G_SELECT [[SELECT]](s32), [[COPY]], [[COPY2]]
119 ; CHECK-NEXT: $x10 = COPY [[SELECT1]](s32)
120 ; CHECK-NEXT: PseudoRET implicit $x10
121 %0:_(s32) = COPY $x10
122 %1:_(s32) = COPY $x11
123 %2:_(s32) = COPY $x12
124 %3:_(s32) = COPY $x13
125 %4:_(s64) = G_MERGE_VALUES %0(s32), %1(s32)
126 %5:_(s64) = G_MERGE_VALUES %2(s32), %3(s32)
127 %6:_(s64) = G_SMAX %4, %5
128 %7:_(s32) = G_TRUNC %6(s64)
130 PseudoRET implicit $x10