1; RUN: llc < %s -mtriple=ve-unknown-unknown | FileCheck %s 2 3declare i128 @llvm.ctlz.i128(i128, i1) 4declare i64 @llvm.ctlz.i64(i64, i1) 5declare i32 @llvm.ctlz.i32(i32, i1) 6declare i16 @llvm.ctlz.i16(i16, i1) 7declare i8 @llvm.ctlz.i8(i8, i1) 8 9define i128 @func128(i128 %p){ 10; CHECK-LABEL: func128: 11; CHECK: # %bb.0: 12; CHECK-NEXT: cmps.l %s2, %s1, (0)1 13; CHECK-NEXT: ldz %s1, %s1 14; CHECK-NEXT: ldz %s0, %s0 15; CHECK-NEXT: lea %s0, 64(, %s0) 16; CHECK-NEXT: cmov.l.ne %s0, %s1, %s2 17; CHECK-NEXT: or %s1, 0, (0)1 18; CHECK-NEXT: b.l.t (, %s10) 19 %r = tail call i128 @llvm.ctlz.i128(i128 %p, i1 true) 20 ret i128 %r 21} 22 23define i64 @func64(i64 %p) { 24; CHECK-LABEL: func64: 25; CHECK: # %bb.0: 26; CHECK-NEXT: ldz %s0, %s0 27; CHECK-NEXT: b.l.t (, %s10) 28 %r = tail call i64 @llvm.ctlz.i64(i64 %p, i1 true) 29 ret i64 %r 30} 31 32define signext i32 @func32s(i32 signext %p) { 33; CHECK-LABEL: func32s: 34; CHECK: # %bb.0: 35; CHECK-NEXT: and %s0, %s0, (32)0 36; CHECK-NEXT: ldz %s0, %s0 37; CHECK-NEXT: lea %s0, -32(, %s0) 38; CHECK-NEXT: and %s0, %s0, (32)0 39; CHECK-NEXT: b.l.t (, %s10) 40 %r = tail call i32 @llvm.ctlz.i32(i32 %p, i1 true) 41 ret i32 %r 42} 43 44define zeroext i32 @func32z(i32 zeroext %p) { 45; CHECK-LABEL: func32z: 46; CHECK: # %bb.0: 47; CHECK-NEXT: ldz %s0, %s0 48; CHECK-NEXT: lea %s0, -32(, %s0) 49; CHECK-NEXT: and %s0, %s0, (32)0 50; CHECK-NEXT: b.l.t (, %s10) 51 %r = tail call i32 @llvm.ctlz.i32(i32 %p, i1 true) 52 ret i32 %r 53} 54 55define signext i16 @func16s(i16 signext %p) { 56; CHECK-LABEL: func16s: 57; CHECK: # %bb.0: 58; CHECK-NEXT: and %s0, %s0, (48)0 59; CHECK-NEXT: ldz %s0, %s0 60; CHECK-NEXT: lea %s0, -32(, %s0) 61; CHECK-NEXT: adds.w.sx %s0, -16, %s0 62; CHECK-NEXT: and %s0, %s0, (48)0 63; CHECK-NEXT: b.l.t (, %s10) 64 %r = tail call i16 @llvm.ctlz.i16(i16 %p, i1 true) 65 ret i16 %r 66} 67 68define zeroext i16 @func16z(i16 zeroext %p) { 69; CHECK-LABEL: func16z: 70; CHECK: # %bb.0: 71; CHECK-NEXT: ldz %s0, %s0 72; CHECK-NEXT: lea %s0, -32(, %s0) 73; CHECK-NEXT: adds.w.sx %s0, -16, %s0 74; CHECK-NEXT: and %s0, %s0, (48)0 75; CHECK-NEXT: b.l.t (, %s10) 76 %r = tail call i16 @llvm.ctlz.i16(i16 %p, i1 true) 77 ret i16 %r 78} 79 80define signext i8 @func8s(i8 signext %p) { 81; CHECK-LABEL: func8s: 82; CHECK: # %bb.0: 83; CHECK-NEXT: and %s0, %s0, (56)0 84; CHECK-NEXT: ldz %s0, %s0 85; CHECK-NEXT: lea %s0, -32(, %s0) 86; CHECK-NEXT: adds.w.sx %s0, -24, %s0 87; CHECK-NEXT: and %s0, %s0, (56)0 88; CHECK-NEXT: b.l.t (, %s10) 89 %r = tail call i8 @llvm.ctlz.i8(i8 %p, i1 true) 90 ret i8 %r 91} 92 93define zeroext i8 @func8z(i8 zeroext %p) { 94; CHECK-LABEL: func8z: 95; CHECK: # %bb.0: 96; CHECK-NEXT: ldz %s0, %s0 97; CHECK-NEXT: lea %s0, -32(, %s0) 98; CHECK-NEXT: adds.w.sx %s0, -24, %s0 99; CHECK-NEXT: and %s0, %s0, (56)0 100; CHECK-NEXT: b.l.t (, %s10) 101 %r = tail call i8 @llvm.ctlz.i8(i8 %p, i1 true) 102 ret i8 %r 103} 104 105define i128 @func128i(){ 106; CHECK-LABEL: func128i: 107; CHECK: # %bb.0: 108; CHECK-NEXT: lea %s0, 112 109; CHECK-NEXT: or %s1, 0, (0)1 110; CHECK-NEXT: b.l.t (, %s10) 111 %r = tail call i128 @llvm.ctlz.i128(i128 65535, i1 true) 112 ret i128 %r 113} 114 115define i64 @func64i() { 116; CHECK-LABEL: func64i: 117; CHECK: # %bb.0: 118; CHECK-NEXT: or %s0, 48, (0)1 119; CHECK-NEXT: b.l.t (, %s10) 120 %r = tail call i64 @llvm.ctlz.i64(i64 65535, i1 true) 121 ret i64 %r 122} 123 124define signext i32 @func32is() { 125; CHECK-LABEL: func32is: 126; CHECK: # %bb.0: 127; CHECK-NEXT: or %s0, 16, (0)1 128; CHECK-NEXT: b.l.t (, %s10) 129 %r = tail call i32 @llvm.ctlz.i32(i32 65535, i1 true) 130 ret i32 %r 131} 132 133define zeroext i32 @func32iz() { 134; CHECK-LABEL: func32iz: 135; CHECK: # %bb.0: 136; CHECK-NEXT: or %s0, 16, (0)1 137; CHECK-NEXT: b.l.t (, %s10) 138 %r = tail call i32 @llvm.ctlz.i32(i32 65535, i1 true) 139 ret i32 %r 140} 141 142define signext i16 @func16is() { 143; CHECK-LABEL: func16is: 144; CHECK: # %bb.0: 145; CHECK-NEXT: or %s0, 8, (0)1 146; CHECK-NEXT: b.l.t (, %s10) 147 %r = tail call i16 @llvm.ctlz.i16(i16 255, i1 true) 148 ret i16 %r 149} 150 151define zeroext i16 @func16iz() { 152; CHECK-LABEL: func16iz: 153; CHECK: # %bb.0: 154; CHECK-NEXT: or %s0, 8, (0)1 155; CHECK-NEXT: b.l.t (, %s10) 156 %r = tail call i16 @llvm.ctlz.i16(i16 255, i1 true) 157 ret i16 %r 158} 159 160define signext i8 @func8is() { 161; CHECK-LABEL: func8is: 162; CHECK: # %bb.0: 163; CHECK-NEXT: or %s0, 0, (0)1 164; CHECK-NEXT: b.l.t (, %s10) 165 %r = tail call i8 @llvm.ctlz.i8(i8 255, i1 true) 166 ret i8 %r 167} 168 169define zeroext i8 @func8iz() { 170; CHECK-LABEL: func8iz: 171; CHECK: # %bb.0: 172; CHECK-NEXT: or %s0, 0, (0)1 173; CHECK-NEXT: b.l.t (, %s10) 174 %r = tail call i8 @llvm.ctlz.i8(i8 255, i1 true) 175 ret i8 %r 176} 177 178define i128 @func128x(i128 %p){ 179; CHECK-LABEL: func128x: 180; CHECK: # %bb.0: 181; CHECK-NEXT: cmps.l %s2, %s1, (0)1 182; CHECK-NEXT: ldz %s1, %s1 183; CHECK-NEXT: ldz %s0, %s0 184; CHECK-NEXT: lea %s0, 64(, %s0) 185; CHECK-NEXT: cmov.l.ne %s0, %s1, %s2 186; CHECK-NEXT: or %s1, 0, (0)1 187; CHECK-NEXT: b.l.t (, %s10) 188 %r = tail call i128 @llvm.ctlz.i128(i128 %p, i1 false) 189 ret i128 %r 190} 191 192define i64 @func64x(i64 %p) { 193; CHECK-LABEL: func64x: 194; CHECK: # %bb.0: 195; CHECK-NEXT: ldz %s0, %s0 196; CHECK-NEXT: b.l.t (, %s10) 197 %r = tail call i64 @llvm.ctlz.i64(i64 %p, i1 false) 198 ret i64 %r 199} 200 201define signext i32 @func32sx(i32 signext %p) { 202; CHECK-LABEL: func32sx: 203; CHECK: # %bb.0: 204; CHECK-NEXT: and %s0, %s0, (32)0 205; CHECK-NEXT: ldz %s0, %s0 206; CHECK-NEXT: lea %s0, -32(, %s0) 207; CHECK-NEXT: and %s0, %s0, (32)0 208; CHECK-NEXT: b.l.t (, %s10) 209 %r = tail call i32 @llvm.ctlz.i32(i32 %p, i1 false) 210 ret i32 %r 211} 212 213define zeroext i32 @func32zx(i32 zeroext %p) { 214; CHECK-LABEL: func32zx: 215; CHECK: # %bb.0: 216; CHECK-NEXT: ldz %s0, %s0 217; CHECK-NEXT: lea %s0, -32(, %s0) 218; CHECK-NEXT: and %s0, %s0, (32)0 219; CHECK-NEXT: b.l.t (, %s10) 220 %r = tail call i32 @llvm.ctlz.i32(i32 %p, i1 false) 221 ret i32 %r 222} 223 224define signext i16 @func16sx(i16 signext %p) { 225; CHECK-LABEL: func16sx: 226; CHECK: # %bb.0: 227; CHECK-NEXT: and %s0, %s0, (48)0 228; CHECK-NEXT: ldz %s0, %s0 229; CHECK-NEXT: lea %s0, -32(, %s0) 230; CHECK-NEXT: adds.w.sx %s0, -16, %s0 231; CHECK-NEXT: and %s0, %s0, (48)0 232; CHECK-NEXT: b.l.t (, %s10) 233 %r = tail call i16 @llvm.ctlz.i16(i16 %p, i1 false) 234 ret i16 %r 235} 236 237define zeroext i16 @func16zx(i16 zeroext %p) { 238; CHECK-LABEL: func16zx: 239; CHECK: # %bb.0: 240; CHECK-NEXT: ldz %s0, %s0 241; CHECK-NEXT: lea %s0, -32(, %s0) 242; CHECK-NEXT: adds.w.sx %s0, -16, %s0 243; CHECK-NEXT: and %s0, %s0, (48)0 244; CHECK-NEXT: b.l.t (, %s10) 245 %r = tail call i16 @llvm.ctlz.i16(i16 %p, i1 false) 246 ret i16 %r 247} 248 249define signext i8 @func8sx(i8 signext %p) { 250; CHECK-LABEL: func8sx: 251; CHECK: # %bb.0: 252; CHECK-NEXT: and %s0, %s0, (56)0 253; CHECK-NEXT: ldz %s0, %s0 254; CHECK-NEXT: lea %s0, -32(, %s0) 255; CHECK-NEXT: adds.w.sx %s0, -24, %s0 256; CHECK-NEXT: and %s0, %s0, (56)0 257; CHECK-NEXT: b.l.t (, %s10) 258 %r = tail call i8 @llvm.ctlz.i8(i8 %p, i1 false) 259 ret i8 %r 260} 261 262define zeroext i8 @func8zx(i8 zeroext %p) { 263; CHECK-LABEL: func8zx: 264; CHECK: # %bb.0: 265; CHECK-NEXT: ldz %s0, %s0 266; CHECK-NEXT: lea %s0, -32(, %s0) 267; CHECK-NEXT: adds.w.sx %s0, -24, %s0 268; CHECK-NEXT: and %s0, %s0, (56)0 269; CHECK-NEXT: b.l.t (, %s10) 270 %r = tail call i8 @llvm.ctlz.i8(i8 %p, i1 false) 271 ret i8 %r 272} 273