1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 3
2 ; RUN: llc -mtriple=riscv32 < %s | FileCheck %s -check-prefix=RV32
3 ; RUN: llc -mtriple=riscv64 < %s | FileCheck %s -check-prefix=RV64
7 define i16 @ctz_v4i32(<4 x i32> %a) {
8 ; RV32-LABEL: ctz_v4i32:
10 ; RV32-NEXT: lw a3, 0(a0)
11 ; RV32-NEXT: lw a1, 4(a0)
12 ; RV32-NEXT: lw a2, 12(a0)
13 ; RV32-NEXT: lw a4, 8(a0)
14 ; RV32-NEXT: seqz a0, a3
15 ; RV32-NEXT: addi a0, a0, -1
16 ; RV32-NEXT: andi a0, a0, 4
17 ; RV32-NEXT: seqz a3, a4
18 ; RV32-NEXT: addi a3, a3, -1
19 ; RV32-NEXT: andi a3, a3, 2
20 ; RV32-NEXT: bltu a3, a0, .LBB0_2
22 ; RV32-NEXT: mv a0, a3
24 ; RV32-NEXT: snez a2, a2
25 ; RV32-NEXT: seqz a1, a1
26 ; RV32-NEXT: addi a1, a1, -1
27 ; RV32-NEXT: andi a1, a1, 3
28 ; RV32-NEXT: bltu a2, a1, .LBB0_4
30 ; RV32-NEXT: mv a1, a2
32 ; RV32-NEXT: bltu a1, a0, .LBB0_6
34 ; RV32-NEXT: mv a0, a1
37 ; RV32-NEXT: sub a1, a1, a0
38 ; RV32-NEXT: andi a0, a1, 255
41 ; RV64-LABEL: ctz_v4i32:
43 ; RV64-NEXT: lw a3, 0(a0)
44 ; RV64-NEXT: lw a1, 8(a0)
45 ; RV64-NEXT: lw a2, 24(a0)
46 ; RV64-NEXT: lw a4, 16(a0)
47 ; RV64-NEXT: seqz a0, a3
48 ; RV64-NEXT: addi a0, a0, -1
49 ; RV64-NEXT: andi a0, a0, 4
50 ; RV64-NEXT: seqz a3, a4
51 ; RV64-NEXT: addi a3, a3, -1
52 ; RV64-NEXT: andi a3, a3, 2
53 ; RV64-NEXT: bltu a3, a0, .LBB0_2
55 ; RV64-NEXT: mv a0, a3
57 ; RV64-NEXT: snez a2, a2
58 ; RV64-NEXT: seqz a1, a1
59 ; RV64-NEXT: addi a1, a1, -1
60 ; RV64-NEXT: andi a1, a1, 3
61 ; RV64-NEXT: bltu a2, a1, .LBB0_4
63 ; RV64-NEXT: mv a1, a2
65 ; RV64-NEXT: bltu a1, a0, .LBB0_6
67 ; RV64-NEXT: mv a0, a1
70 ; RV64-NEXT: subw a1, a1, a0
71 ; RV64-NEXT: andi a0, a1, 255
73 %res = call i16 @llvm.experimental.cttz.elts.i16.v4i32(<4 x i32> %a, i1 0)
79 define i32 @ctz_v2i1_poison(<2 x i1> %a) {
80 ; RV32-LABEL: ctz_v2i1_poison:
82 ; RV32-NEXT: andi a1, a1, 1
83 ; RV32-NEXT: slli a0, a0, 31
84 ; RV32-NEXT: srai a0, a0, 31
85 ; RV32-NEXT: andi a0, a0, 2
86 ; RV32-NEXT: bltu a1, a0, .LBB1_2
88 ; RV32-NEXT: mv a0, a1
91 ; RV32-NEXT: sub a1, a1, a0
92 ; RV32-NEXT: andi a0, a1, 255
95 ; RV64-LABEL: ctz_v2i1_poison:
97 ; RV64-NEXT: andi a1, a1, 1
98 ; RV64-NEXT: slli a0, a0, 63
99 ; RV64-NEXT: srai a0, a0, 63
100 ; RV64-NEXT: andi a0, a0, 2
101 ; RV64-NEXT: bltu a1, a0, .LBB1_2
102 ; RV64-NEXT: # %bb.1:
103 ; RV64-NEXT: mv a0, a1
104 ; RV64-NEXT: .LBB1_2:
105 ; RV64-NEXT: li a1, 2
106 ; RV64-NEXT: subw a1, a1, a0
107 ; RV64-NEXT: andi a0, a1, 255
109 %res = call i32 @llvm.experimental.cttz.elts.i32.v2i1(<2 x i1> %a, i1 1)
113 declare i32 @llvm.experimental.cttz.elts.i32.v2i1(<2 x i1>, i1)
114 declare i16 @llvm.experimental.cttz.elts.i16.v4i32(<4 x i32>, i1)