1; NOTE: Assertions have been autogenerated by utils/update_analyze_test_checks.py 2; RUN: opt < %s -mtriple=aarch64 -passes="print<cost-model>" 2>&1 -disable-output | FileCheck %s 3 4; Verify the cost of scalar ctlz instructions. 5 6target datalayout = "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128" 7 8define i64 @test_cttz_i64(i64 %a) { 9; 10; CHECK-LABEL: 'test_cttz_i64' 11; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %cttz = call i64 @llvm.cttz.i64(i64 %a, i1 false) 12; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret i64 %cttz 13; 14 %cttz = call i64 @llvm.cttz.i64(i64 %a) 15 ret i64 %cttz 16} 17 18define i32 @test_cttz_i32(i32 %a) { 19; 20; CHECK-LABEL: 'test_cttz_i32' 21; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %cttz = call i32 @llvm.cttz.i32(i32 %a, i1 false) 22; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret i32 %cttz 23; 24 %cttz = call i32 @llvm.cttz.i32(i32 %a) 25 ret i32 %cttz 26} 27 28define i16 @test_cttz_i16(i16 %a) { 29; 30; CHECK-LABEL: 'test_cttz_i16' 31; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %cttz = call i16 @llvm.cttz.i16(i16 %a, i1 false) 32; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret i16 %cttz 33; 34 %cttz = call i16 @llvm.cttz.i16(i16 %a) 35 ret i16 %cttz 36} 37 38define i8 @test_cttz_i8(i8 %a) { 39; 40; CHECK-LABEL: 'test_cttz_i8' 41; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %cttz = call i8 @llvm.cttz.i8(i8 %a, i1 false) 42; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret i8 %cttz 43; 44 %cttz = call i8 @llvm.cttz.i8(i8 %a) 45 ret i8 %cttz 46} 47 48declare i64 @llvm.cttz.i64(i64) 49declare i32 @llvm.cttz.i32(i32) 50declare i16 @llvm.cttz.i16(i16) 51declare i8 @llvm.cttz.i8(i8) 52 53; Verify the cost of vector cttz instructions. 54 55define <2 x i64> @test_cttz_v2i64(<2 x i64> %a) { 56; 57; CHECK-LABEL: 'test_cttz_v2i64' 58; CHECK-NEXT: Cost Model: Found an estimated cost of 10 for instruction: %cttz = call <2 x i64> @llvm.cttz.v2i64(<2 x i64> %a, i1 true) 59; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret <2 x i64> %cttz 60; 61 %cttz = call <2 x i64> @llvm.cttz.v2i64(<2 x i64> %a, i1 true) 62 ret <2 x i64> %cttz 63} 64 65define <2 x i32> @test_cttz_v2i32(<2 x i32> %a) { 66; 67; CHECK-LABEL: 'test_cttz_v2i32' 68; CHECK-NEXT: Cost Model: Found an estimated cost of 10 for instruction: %cttz = call <2 x i32> @llvm.cttz.v2i32(<2 x i32> %a, i1 true) 69; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret <2 x i32> %cttz 70; 71 %cttz = call <2 x i32> @llvm.cttz.v2i32(<2 x i32> %a, i1 true) 72 ret <2 x i32> %cttz 73} 74 75define <4 x i32> @test_cttz_v4i32(<4 x i32> %a) { 76; 77; CHECK-LABEL: 'test_cttz_v4i32' 78; CHECK-NEXT: Cost Model: Found an estimated cost of 20 for instruction: %cttz = call <4 x i32> @llvm.cttz.v4i32(<4 x i32> %a, i1 true) 79; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret <4 x i32> %cttz 80; 81 %cttz = call <4 x i32> @llvm.cttz.v4i32(<4 x i32> %a, i1 true) 82 ret <4 x i32> %cttz 83} 84 85define <2 x i16> @test_cttz_v2i16(<2 x i16> %a) { 86; 87; CHECK-LABEL: 'test_cttz_v2i16' 88; CHECK-NEXT: Cost Model: Found an estimated cost of 10 for instruction: %cttz = call <2 x i16> @llvm.cttz.v2i16(<2 x i16> %a, i1 true) 89; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret <2 x i16> %cttz 90; 91 %cttz = call <2 x i16> @llvm.cttz.v2i16(<2 x i16> %a, i1 true) 92 ret <2 x i16> %cttz 93} 94 95define <4 x i16> @test_cttz_v4i16(<4 x i16> %a) { 96; 97; CHECK-LABEL: 'test_cttz_v4i16' 98; CHECK-NEXT: Cost Model: Found an estimated cost of 20 for instruction: %cttz = call <4 x i16> @llvm.cttz.v4i16(<4 x i16> %a, i1 true) 99; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret <4 x i16> %cttz 100; 101 %cttz = call <4 x i16> @llvm.cttz.v4i16(<4 x i16> %a, i1 true) 102 ret <4 x i16> %cttz 103} 104 105define <8 x i16> @test_cttz_v8i16(<8 x i16> %a) { 106; 107; CHECK-LABEL: 'test_cttz_v8i16' 108; CHECK-NEXT: Cost Model: Found an estimated cost of 40 for instruction: %cttz = call <8 x i16> @llvm.cttz.v8i16(<8 x i16> %a, i1 true) 109; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret <8 x i16> %cttz 110; 111 %cttz = call <8 x i16> @llvm.cttz.v8i16(<8 x i16> %a, i1 true) 112 ret <8 x i16> %cttz 113} 114 115define <2 x i8> @test_cttz_v2i8(<2 x i8> %a) { 116; 117; CHECK-LABEL: 'test_cttz_v2i8' 118; CHECK-NEXT: Cost Model: Found an estimated cost of 10 for instruction: %cttz = call <2 x i8> @llvm.cttz.v2i8(<2 x i8> %a, i1 true) 119; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret <2 x i8> %cttz 120; 121 %cttz = call <2 x i8> @llvm.cttz.v2i8(<2 x i8> %a, i1 true) 122 ret <2 x i8> %cttz 123} 124 125define <4 x i8> @test_cttz_v4i8(<4 x i8> %a) { 126; 127; CHECK-LABEL: 'test_cttz_v4i8' 128; CHECK-NEXT: Cost Model: Found an estimated cost of 20 for instruction: %cttz = call <4 x i8> @llvm.cttz.v4i8(<4 x i8> %a, i1 true) 129; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret <4 x i8> %cttz 130; 131 %cttz = call <4 x i8> @llvm.cttz.v4i8(<4 x i8> %a, i1 true) 132 ret <4 x i8> %cttz 133} 134 135define <8 x i8> @test_cttz_v8i8(<8 x i8> %a) { 136; 137; CHECK-LABEL: 'test_cttz_v8i8' 138; CHECK-NEXT: Cost Model: Found an estimated cost of 40 for instruction: %cttz = call <8 x i8> @llvm.cttz.v8i8(<8 x i8> %a, i1 true) 139; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret <8 x i8> %cttz 140; 141 %cttz = call <8 x i8> @llvm.cttz.v8i8(<8 x i8> %a, i1 true) 142 ret <8 x i8> %cttz 143} 144 145define <16 x i8> @test_cttz_v16i8(<16 x i8> %a) { 146; 147; CHECK-LABEL: 'test_cttz_v16i8' 148; CHECK-NEXT: Cost Model: Found an estimated cost of 80 for instruction: %cttz = call <16 x i8> @llvm.cttz.v16i8(<16 x i8> %a, i1 true) 149; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret <16 x i8> %cttz 150; 151 %cttz = call <16 x i8> @llvm.cttz.v16i8(<16 x i8> %a, i1 true) 152 ret <16 x i8> %cttz 153} 154 155define <4 x i64> @test_cttz_v4i64(<4 x i64> %a) { 156; 157; CHECK-LABEL: 'test_cttz_v4i64' 158; CHECK-NEXT: Cost Model: Found an estimated cost of 20 for instruction: %cttz = call <4 x i64> @llvm.cttz.v4i64(<4 x i64> %a, i1 true) 159; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret <4 x i64> %cttz 160; 161 %cttz = call <4 x i64> @llvm.cttz.v4i64(<4 x i64> %a, i1 true) 162 ret <4 x i64> %cttz 163} 164 165define <8 x i32> @test_cttz_v8i32(<8 x i32> %a) { 166; 167; CHECK-LABEL: 'test_cttz_v8i32' 168; CHECK-NEXT: Cost Model: Found an estimated cost of 40 for instruction: %cttz = call <8 x i32> @llvm.cttz.v8i32(<8 x i32> %a, i1 true) 169; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret <8 x i32> %cttz 170; 171 %cttz = call <8 x i32> @llvm.cttz.v8i32(<8 x i32> %a, i1 true) 172 ret <8 x i32> %cttz 173} 174 175define <16 x i16> @test_cttz_v16i16(<16 x i16> %a) { 176; 177; CHECK-LABEL: 'test_cttz_v16i16' 178; CHECK-NEXT: Cost Model: Found an estimated cost of 80 for instruction: %cttz = call <16 x i16> @llvm.cttz.v16i16(<16 x i16> %a, i1 true) 179; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret <16 x i16> %cttz 180; 181 %cttz = call <16 x i16> @llvm.cttz.v16i16(<16 x i16> %a, i1 true) 182 ret <16 x i16> %cttz 183} 184 185define <32 x i8> @test_cttz_v32i8(<32 x i8> %a) { 186; 187; CHECK-LABEL: 'test_cttz_v32i8' 188; CHECK-NEXT: Cost Model: Found an estimated cost of 160 for instruction: %cttz = call <32 x i8> @llvm.cttz.v32i8(<32 x i8> %a, i1 true) 189; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret <32 x i8> %cttz 190; 191 %cttz = call <32 x i8> @llvm.cttz.v32i8(<32 x i8> %a, i1 true) 192 ret <32 x i8> %cttz 193} 194 195declare <2 x i64> @llvm.cttz.v2i64(<2 x i64>, i1) 196declare <2 x i32> @llvm.cttz.v2i32(<2 x i32>, i1) 197declare <4 x i32> @llvm.cttz.v4i32(<4 x i32>, i1) 198declare <2 x i16> @llvm.cttz.v2i16(<2 x i16>, i1) 199declare <4 x i16> @llvm.cttz.v4i16(<4 x i16>, i1) 200declare <8 x i16> @llvm.cttz.v8i16(<8 x i16>, i1) 201declare <2 x i8> @llvm.cttz.v2i8(<2 x i8>, i1) 202declare <4 x i8> @llvm.cttz.v4i8(<4 x i8>, i1) 203declare <8 x i8> @llvm.cttz.v8i8(<8 x i8>, i1) 204declare <16 x i8> @llvm.cttz.v16i8(<16 x i8>, i1) 205 206declare <4 x i64> @llvm.cttz.v4i64(<4 x i64>, i1) 207declare <8 x i32> @llvm.cttz.v8i32(<8 x i32>, i1) 208declare <16 x i16> @llvm.cttz.v16i16(<16 x i16>, i1) 209declare <32 x i8> @llvm.cttz.v32i8(<32 x i8>, i1) 210