1; RUN: llc < %s -mtriple=ve-unknown-unknown | FileCheck %s 2 3declare i128 @llvm.cttz.i128(i128, i1) 4declare i64 @llvm.cttz.i64(i64, i1) 5declare i32 @llvm.cttz.i32(i32, i1) 6declare i16 @llvm.cttz.i16(i16, i1) 7declare i8 @llvm.cttz.i8(i8, i1) 8 9define i128 @func128(i128 %p) { 10; CHECK-LABEL: func128: 11; CHECK: # %bb.0: 12; CHECK-NEXT: cmps.l %s2, %s0, (0)1 13; CHECK-NEXT: lea %s3, -1(, %s0) 14; CHECK-NEXT: nnd %s0, %s0, %s3 15; CHECK-NEXT: pcnt %s3, %s0 16; CHECK-NEXT: lea %s0, -1(, %s1) 17; CHECK-NEXT: nnd %s0, %s1, %s0 18; CHECK-NEXT: pcnt %s0, %s0 19; CHECK-NEXT: lea %s0, 64(, %s0) 20; CHECK-NEXT: cmov.l.ne %s0, %s3, %s2 21; CHECK-NEXT: or %s1, 0, (0)1 22; CHECK-NEXT: b.l.t (, %s10) 23 %r = tail call i128 @llvm.cttz.i128(i128 %p, i1 true) 24 ret i128 %r 25} 26 27define i64 @func64(i64 %p) { 28; CHECK-LABEL: func64: 29; CHECK: # %bb.0: 30; CHECK-NEXT: lea %s1, -1(, %s0) 31; CHECK-NEXT: nnd %s0, %s0, %s1 32; CHECK-NEXT: pcnt %s0, %s0 33; CHECK-NEXT: b.l.t (, %s10) 34 %r = tail call i64 @llvm.cttz.i64(i64 %p, i1 true) 35 ret i64 %r 36} 37 38define signext i32 @func32s(i32 signext %p) { 39; CHECK-LABEL: func32s: 40; CHECK: # %bb.0: 41; CHECK-NEXT: adds.w.sx %s1, -1, %s0 42; CHECK-NEXT: nnd %s0, %s0, %s1 43; CHECK-NEXT: and %s0, %s0, (32)0 44; CHECK-NEXT: pcnt %s0, %s0 45; CHECK-NEXT: b.l.t (, %s10) 46 %r = tail call i32 @llvm.cttz.i32(i32 %p, i1 true) 47 ret i32 %r 48} 49 50define zeroext i32 @func32z(i32 zeroext %p) { 51; CHECK-LABEL: func32z: 52; CHECK: # %bb.0: 53; CHECK-NEXT: adds.w.sx %s1, -1, %s0 54; CHECK-NEXT: nnd %s0, %s0, %s1 55; CHECK-NEXT: and %s0, %s0, (32)0 56; CHECK-NEXT: pcnt %s0, %s0 57; CHECK-NEXT: b.l.t (, %s10) 58 %r = tail call i32 @llvm.cttz.i32(i32 %p, i1 true) 59 ret i32 %r 60} 61 62define signext i16 @func16s(i16 signext %p) { 63; CHECK-LABEL: func16s: 64; CHECK: # %bb.0: 65; CHECK-NEXT: adds.w.sx %s1, -1, %s0 66; CHECK-NEXT: nnd %s0, %s0, %s1 67; CHECK-NEXT: and %s0, %s0, (32)0 68; CHECK-NEXT: pcnt %s0, %s0 69; CHECK-NEXT: b.l.t (, %s10) 70 %r = tail call i16 @llvm.cttz.i16(i16 %p, i1 true) 71 ret i16 %r 72} 73 74define zeroext i16 @func16z(i16 zeroext %p) { 75; CHECK-LABEL: func16z: 76; CHECK: # %bb.0: 77; CHECK-NEXT: adds.w.sx %s1, -1, %s0 78; CHECK-NEXT: nnd %s0, %s0, %s1 79; CHECK-NEXT: and %s0, %s0, (32)0 80; CHECK-NEXT: pcnt %s0, %s0 81; CHECK-NEXT: b.l.t (, %s10) 82 %r = tail call i16 @llvm.cttz.i16(i16 %p, i1 true) 83 ret i16 %r 84} 85 86define signext i8 @func8s(i8 signext %p) { 87; CHECK-LABEL: func8s: 88; CHECK: # %bb.0: 89; CHECK-NEXT: adds.w.sx %s1, -1, %s0 90; CHECK-NEXT: nnd %s0, %s0, %s1 91; CHECK-NEXT: and %s0, %s0, (32)0 92; CHECK-NEXT: pcnt %s0, %s0 93; CHECK-NEXT: b.l.t (, %s10) 94 %r = tail call i8 @llvm.cttz.i8(i8 %p, i1 true) 95 ret i8 %r 96} 97 98define zeroext i8 @func8z(i8 zeroext %p) { 99; CHECK-LABEL: func8z: 100; CHECK: # %bb.0: 101; CHECK-NEXT: adds.w.sx %s1, -1, %s0 102; CHECK-NEXT: nnd %s0, %s0, %s1 103; CHECK-NEXT: and %s0, %s0, (32)0 104; CHECK-NEXT: pcnt %s0, %s0 105; CHECK-NEXT: b.l.t (, %s10) 106 %r = tail call i8 @llvm.cttz.i8(i8 %p, i1 true) 107 ret i8 %r 108} 109 110define i128 @func128i() { 111; CHECK-LABEL: func128i: 112; CHECK: # %bb.0: 113; CHECK-NEXT: or %s0, 8, (0)1 114; CHECK-NEXT: or %s1, 0, (0)1 115; CHECK-NEXT: b.l.t (, %s10) 116 %r = tail call i128 @llvm.cttz.i128(i128 65280, i1 true) 117 ret i128 %r 118} 119 120define i64 @func64i() { 121; CHECK-LABEL: func64i: 122; CHECK: # %bb.0: 123; CHECK-NEXT: or %s0, 8, (0)1 124; CHECK-NEXT: b.l.t (, %s10) 125 %r = tail call i64 @llvm.cttz.i64(i64 65280, i1 true) 126 ret i64 %r 127} 128 129define signext i32 @func32is() { 130; CHECK-LABEL: func32is: 131; CHECK: # %bb.0: 132; CHECK-NEXT: or %s0, 8, (0)1 133; CHECK-NEXT: b.l.t (, %s10) 134 %r = tail call i32 @llvm.cttz.i32(i32 65280, i1 true) 135 ret i32 %r 136} 137 138define zeroext i32 @func32iz() { 139; CHECK-LABEL: func32iz: 140; CHECK: # %bb.0: 141; CHECK-NEXT: or %s0, 8, (0)1 142; CHECK-NEXT: b.l.t (, %s10) 143 %r = tail call i32 @llvm.cttz.i32(i32 65280, i1 true) 144 ret i32 %r 145} 146 147define signext i16 @func16is() { 148; CHECK-LABEL: func16is: 149; CHECK: # %bb.0: 150; CHECK-NEXT: or %s0, 8, (0)1 151; CHECK-NEXT: b.l.t (, %s10) 152 %r = tail call i16 @llvm.cttz.i16(i16 65280, i1 true) 153 ret i16 %r 154} 155 156define zeroext i16 @func16iz() { 157; CHECK-LABEL: func16iz: 158; CHECK: # %bb.0: 159; CHECK-NEXT: or %s0, 8, (0)1 160; CHECK-NEXT: b.l.t (, %s10) 161 %r = tail call i16 @llvm.cttz.i16(i16 65280, i1 true) 162 ret i16 %r 163} 164 165define signext i8 @func8is() { 166; CHECK-LABEL: func8is: 167; CHECK: # %bb.0: 168; CHECK-NEXT: or %s0, 4, (0)1 169; CHECK-NEXT: b.l.t (, %s10) 170 %r = tail call i8 @llvm.cttz.i8(i8 240, i1 true) 171 ret i8 %r 172} 173 174define zeroext i8 @func8iz() { 175; CHECK-LABEL: func8iz: 176; CHECK: # %bb.0: 177; CHECK-NEXT: or %s0, 4, (0)1 178; CHECK-NEXT: b.l.t (, %s10) 179 %r = tail call i8 @llvm.cttz.i8(i8 240, i1 true) 180 ret i8 %r 181} 182