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_ctlz_i64(i64 %a) { 9; 10; CHECK-LABEL: 'test_ctlz_i64' 11; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %ctlz = call i64 @llvm.ctlz.i64(i64 %a, i1 false) 12; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret i64 %ctlz 13; 14 %ctlz = call i64 @llvm.ctlz.i64(i64 %a) 15 ret i64 %ctlz 16} 17 18define i32 @test_ctlz_i32(i32 %a) { 19; 20; CHECK-LABEL: 'test_ctlz_i32' 21; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %ctlz = call i32 @llvm.ctlz.i32(i32 %a, i1 false) 22; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret i32 %ctlz 23; 24 %ctlz = call i32 @llvm.ctlz.i32(i32 %a) 25 ret i32 %ctlz 26} 27 28define i16 @test_ctlz_i16(i16 %a) { 29; 30; CHECK-LABEL: 'test_ctlz_i16' 31; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %ctlz = call i16 @llvm.ctlz.i16(i16 %a, i1 false) 32; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret i16 %ctlz 33; 34 %ctlz = call i16 @llvm.ctlz.i16(i16 %a) 35 ret i16 %ctlz 36} 37 38define i8 @test_ctlz_i8(i8 %a) { 39; 40; CHECK-LABEL: 'test_ctlz_i8' 41; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %ctlz = call i8 @llvm.ctlz.i8(i8 %a, i1 false) 42; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret i8 %ctlz 43; 44 %ctlz = call i8 @llvm.ctlz.i8(i8 %a) 45 ret i8 %ctlz 46} 47 48declare i64 @llvm.ctlz.i64(i64) 49declare i32 @llvm.ctlz.i32(i32) 50declare i16 @llvm.ctlz.i16(i16) 51declare i8 @llvm.ctlz.i8(i8) 52 53; Verify the cost of vector ctlz instructions. 54 55define <2 x i64> @test_ctlz_v2i64(<2 x i64> %a) { 56; 57; CHECK-LABEL: 'test_ctlz_v2i64' 58; CHECK-NEXT: Cost Model: Found an estimated cost of 10 for instruction: %ctlz = call <2 x i64> @llvm.ctlz.v2i64(<2 x i64> %a, i1 false) 59; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret <2 x i64> %ctlz 60; 61 %ctlz = call <2 x i64> @llvm.ctlz.v2i64(<2 x i64> %a, i1 false) 62 ret <2 x i64> %ctlz 63} 64 65define <2 x i32> @test_ctlz_v2i32(<2 x i32> %a) { 66; 67; CHECK-LABEL: 'test_ctlz_v2i32' 68; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %ctlz = call <2 x i32> @llvm.ctlz.v2i32(<2 x i32> %a, i1 false) 69; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret <2 x i32> %ctlz 70; 71 %ctlz = call <2 x i32> @llvm.ctlz.v2i32(<2 x i32> %a, i1 false) 72 ret <2 x i32> %ctlz 73} 74 75define <4 x i32> @test_ctlz_v4i32(<4 x i32> %a) { 76; 77; CHECK-LABEL: 'test_ctlz_v4i32' 78; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %ctlz = call <4 x i32> @llvm.ctlz.v4i32(<4 x i32> %a, i1 false) 79; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret <4 x i32> %ctlz 80; 81 %ctlz = call <4 x i32> @llvm.ctlz.v4i32(<4 x i32> %a, i1 false) 82 ret <4 x i32> %ctlz 83} 84 85define <2 x i16> @test_ctlz_v2i16(<2 x i16> %a) { 86; 87; CHECK-LABEL: 'test_ctlz_v2i16' 88; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %ctlz = call <2 x i16> @llvm.ctlz.v2i16(<2 x i16> %a, i1 false) 89; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret <2 x i16> %ctlz 90; 91 %ctlz = call <2 x i16> @llvm.ctlz.v2i16(<2 x i16> %a, i1 false) 92 ret <2 x i16> %ctlz 93} 94 95define <4 x i16> @test_ctlz_v4i16(<4 x i16> %a) { 96; 97; CHECK-LABEL: 'test_ctlz_v4i16' 98; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %ctlz = call <4 x i16> @llvm.ctlz.v4i16(<4 x i16> %a, i1 false) 99; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret <4 x i16> %ctlz 100; 101 %ctlz = call <4 x i16> @llvm.ctlz.v4i16(<4 x i16> %a, i1 false) 102 ret <4 x i16> %ctlz 103} 104 105define <8 x i16> @test_ctlz_v8i16(<8 x i16> %a) { 106; 107; CHECK-LABEL: 'test_ctlz_v8i16' 108; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %ctlz = call <8 x i16> @llvm.ctlz.v8i16(<8 x i16> %a, i1 false) 109; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret <8 x i16> %ctlz 110; 111 %ctlz = call <8 x i16> @llvm.ctlz.v8i16(<8 x i16> %a, i1 false) 112 ret <8 x i16> %ctlz 113} 114 115define <2 x i8> @test_ctlz_v2i8(<2 x i8> %a) { 116; 117; CHECK-LABEL: 'test_ctlz_v2i8' 118; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %ctlz = call <2 x i8> @llvm.ctlz.v2i8(<2 x i8> %a, i1 false) 119; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret <2 x i8> %ctlz 120; 121 %ctlz = call <2 x i8> @llvm.ctlz.v2i8(<2 x i8> %a, i1 false) 122 ret <2 x i8> %ctlz 123} 124 125define <4 x i8> @test_ctlz_v4i8(<4 x i8> %a) { 126; 127; CHECK-LABEL: 'test_ctlz_v4i8' 128; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %ctlz = call <4 x i8> @llvm.ctlz.v4i8(<4 x i8> %a, i1 false) 129; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret <4 x i8> %ctlz 130; 131 %ctlz = call <4 x i8> @llvm.ctlz.v4i8(<4 x i8> %a, i1 false) 132 ret <4 x i8> %ctlz 133} 134 135define <8 x i8> @test_ctlz_v8i8(<8 x i8> %a) { 136; 137; CHECK-LABEL: 'test_ctlz_v8i8' 138; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %ctlz = call <8 x i8> @llvm.ctlz.v8i8(<8 x i8> %a, i1 false) 139; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret <8 x i8> %ctlz 140; 141 %ctlz = call <8 x i8> @llvm.ctlz.v8i8(<8 x i8> %a, i1 false) 142 ret <8 x i8> %ctlz 143} 144 145define <16 x i8> @test_ctlz_v16i8(<16 x i8> %a) { 146; 147; CHECK-LABEL: 'test_ctlz_v16i8' 148; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %ctlz = call <16 x i8> @llvm.ctlz.v16i8(<16 x i8> %a, i1 false) 149; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret <16 x i8> %ctlz 150; 151 %ctlz = call <16 x i8> @llvm.ctlz.v16i8(<16 x i8> %a, i1 false) 152 ret <16 x i8> %ctlz 153} 154 155define <4 x i64> @test_ctlz_v4i64(<4 x i64> %a) { 156; CHECK-LABEL: 'test_ctlz_v4i64' 157; CHECK-NEXT: Cost Model: Found an estimated cost of 20 for instruction: %ctlz = call <4 x i64> @llvm.ctlz.v4i64(<4 x i64> %a, i1 false) 158; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret <4 x i64> %ctlz 159; 160 %ctlz = call <4 x i64> @llvm.ctlz.v4i64(<4 x i64> %a, i1 false) 161 ret <4 x i64> %ctlz 162} 163 164define <8 x i32> @test_ctlz_v8i32(<8 x i32> %a) { 165; CHECK-LABEL: 'test_ctlz_v8i32' 166; CHECK-NEXT: Cost Model: Found an estimated cost of 4 for instruction: %ctlz = call <8 x i32> @llvm.ctlz.v8i32(<8 x i32> %a, i1 false) 167; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret <8 x i32> %ctlz 168; 169 %ctlz = call <8 x i32> @llvm.ctlz.v8i32(<8 x i32> %a, i1 false) 170 ret <8 x i32> %ctlz 171} 172 173define <16 x i16> @test_ctlz_v16i16(<16 x i16> %a) { 174; CHECK-LABEL: 'test_ctlz_v16i16' 175; CHECK-NEXT: Cost Model: Found an estimated cost of 4 for instruction: %ctlz = call <16 x i16> @llvm.ctlz.v16i16(<16 x i16> %a, i1 false) 176; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret <16 x i16> %ctlz 177; 178 %ctlz = call <16 x i16> @llvm.ctlz.v16i16(<16 x i16> %a, i1 false) 179 ret <16 x i16> %ctlz 180} 181 182define <32 x i8> @test_ctlz_v32i8(<32 x i8> %a) { 183; CHECK-LABEL: 'test_ctlz_v32i8' 184; CHECK-NEXT: Cost Model: Found an estimated cost of 4 for instruction: %ctlz = call <32 x i8> @llvm.ctlz.v32i8(<32 x i8> %a, i1 false) 185; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret <32 x i8> %ctlz 186; 187 %ctlz = call <32 x i8> @llvm.ctlz.v32i8(<32 x i8> %a, i1 false) 188 ret <32 x i8> %ctlz 189} 190 191declare <2 x i64> @llvm.ctlz.v2i64(<2 x i64>, i1) 192declare <2 x i32> @llvm.ctlz.v2i32(<2 x i32>, i1) 193declare <4 x i32> @llvm.ctlz.v4i32(<4 x i32>, i1) 194declare <2 x i16> @llvm.ctlz.v2i16(<2 x i16>, i1) 195declare <4 x i16> @llvm.ctlz.v4i16(<4 x i16>, i1) 196declare <8 x i16> @llvm.ctlz.v8i16(<8 x i16>, i1) 197declare <2 x i8> @llvm.ctlz.v2i8(<2 x i8>, i1) 198declare <4 x i8> @llvm.ctlz.v4i8(<4 x i8>, i1) 199declare <8 x i8> @llvm.ctlz.v8i8(<8 x i8>, i1) 200declare <16 x i8> @llvm.ctlz.v16i8(<16 x i8>, i1) 201 202declare <4 x i64> @llvm.ctlz.v4i64(<4 x i64>, i1) 203declare <8 x i32> @llvm.ctlz.v8i32(<8 x i32>, i1) 204declare <16 x i16> @llvm.ctlz.v16i16(<16 x i16>, i1) 205declare <32 x i8> @llvm.ctlz.v32i8(<32 x i8>, i1) 206 207