1; NOTE: Assertions have been autogenerated by utils/update_analyze_test_checks.py UTC_ARGS: --version 2 2; RUN: opt -passes="print<cost-model>" 2>&1 -disable-output -mtriple=aarch64--linux-gnu < %s | FileCheck %s 3 4target datalayout = "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128" 5target triple = "aarch64--linux-gnu" 6 7define i8 @test1(ptr %p) { 8; CHECK-LABEL: 'test1' 9; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %a = getelementptr inbounds i8, ptr %p, i32 1 10; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v = load i8, ptr %a, align 1 11; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret i8 %v 12; 13 %a = getelementptr inbounds i8, ptr %p, i32 1 14 %v = load i8, ptr %a 15 ret i8 %v 16} 17 18define i16 @test2(ptr %p) { 19; CHECK-LABEL: 'test2' 20; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %a = getelementptr inbounds i16, ptr %p, i32 1 21; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v = load i16, ptr %a, align 2 22; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret i16 %v 23; 24 %a = getelementptr inbounds i16, ptr %p, i32 1 25 %v = load i16, ptr %a 26 ret i16 %v 27} 28 29define i32 @test3(ptr %p) { 30; CHECK-LABEL: 'test3' 31; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %a = getelementptr inbounds i32, ptr %p, i32 1 32; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v = load i32, ptr %a, align 4 33; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret i32 %v 34; 35 %a = getelementptr inbounds i32, ptr %p, i32 1 36 %v = load i32, ptr %a 37 ret i32 %v 38} 39 40define i64 @test4(ptr %p) { 41; CHECK-LABEL: 'test4' 42; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %a = getelementptr inbounds i64, ptr %p, i32 1 43; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v = load i64, ptr %a, align 8 44; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret i64 %v 45; 46 %a = getelementptr inbounds i64, ptr %p, i32 1 47 %v = load i64, ptr %a 48 ret i64 %v 49} 50 51define i8 @test5(ptr %p) { 52; CHECK-LABEL: 'test5' 53; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %a = getelementptr inbounds i8, ptr %p, i32 1024 54; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v = load i8, ptr %a, align 1 55; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret i8 %v 56; 57 %a = getelementptr inbounds i8, ptr %p, i32 1024 58 %v = load i8, ptr %a 59 ret i8 %v 60} 61 62define i16 @test6(ptr %p) { 63; CHECK-LABEL: 'test6' 64; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %a = getelementptr inbounds i16, ptr %p, i32 1024 65; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v = load i16, ptr %a, align 2 66; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret i16 %v 67; 68 %a = getelementptr inbounds i16, ptr %p, i32 1024 69 %v = load i16, ptr %a 70 ret i16 %v 71} 72 73define i32 @test7(ptr %p) { 74; CHECK-LABEL: 'test7' 75; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %a = getelementptr inbounds i32, ptr %p, i32 1024 76; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v = load i32, ptr %a, align 4 77; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret i32 %v 78; 79 %a = getelementptr inbounds i32, ptr %p, i32 1024 80 %v = load i32, ptr %a 81 ret i32 %v 82} 83 84define i64 @test8(ptr %p) { 85; CHECK-LABEL: 'test8' 86; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %a = getelementptr inbounds i64, ptr %p, i32 1024 87; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v = load i64, ptr %a, align 8 88; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret i64 %v 89; 90 %a = getelementptr inbounds i64, ptr %p, i32 1024 91 %v = load i64, ptr %a 92 ret i64 %v 93} 94 95define i8 @test9(ptr %p) { 96; CHECK-LABEL: 'test9' 97; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %a = getelementptr inbounds i8, ptr %p, i32 4096 98; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v = load i8, ptr %a, align 1 99; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret i8 %v 100; 101 %a = getelementptr inbounds i8, ptr %p, i32 4096 102 %v = load i8, ptr %a 103 ret i8 %v 104} 105 106define i16 @test10(ptr %p) { 107; CHECK-LABEL: 'test10' 108; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %a = getelementptr inbounds i16, ptr %p, i32 4096 109; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v = load i16, ptr %a, align 2 110; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret i16 %v 111; 112 %a = getelementptr inbounds i16, ptr %p, i32 4096 113 %v = load i16, ptr %a 114 ret i16 %v 115} 116 117define i32 @test11(ptr %p) { 118; CHECK-LABEL: 'test11' 119; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %a = getelementptr inbounds i32, ptr %p, i32 4096 120; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v = load i32, ptr %a, align 4 121; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret i32 %v 122; 123 %a = getelementptr inbounds i32, ptr %p, i32 4096 124 %v = load i32, ptr %a 125 ret i32 %v 126} 127 128define i64 @test12(ptr %p) { 129; CHECK-LABEL: 'test12' 130; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %a = getelementptr inbounds i64, ptr %p, i32 4096 131; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v = load i64, ptr %a, align 8 132; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret i64 %v 133; 134 %a = getelementptr inbounds i64, ptr %p, i32 4096 135 %v = load i64, ptr %a 136 ret i64 %v 137} 138 139define i8 @test13(ptr %p) { 140; CHECK-LABEL: 'test13' 141; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %a = getelementptr inbounds i8, ptr %p, i32 -64 142; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v = load i8, ptr %a, align 1 143; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret i8 %v 144; 145 %a = getelementptr inbounds i8, ptr %p, i32 -64 146 %v = load i8, ptr %a 147 ret i8 %v 148} 149 150define i16 @test14(ptr %p) { 151; CHECK-LABEL: 'test14' 152; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %a = getelementptr inbounds i16, ptr %p, i32 -64 153; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v = load i16, ptr %a, align 2 154; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret i16 %v 155; 156 %a = getelementptr inbounds i16, ptr %p, i32 -64 157 %v = load i16, ptr %a 158 ret i16 %v 159} 160 161define i32 @test15(ptr %p) { 162; CHECK-LABEL: 'test15' 163; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %a = getelementptr inbounds i32, ptr %p, i32 -64 164; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v = load i32, ptr %a, align 4 165; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret i32 %v 166; 167 %a = getelementptr inbounds i32, ptr %p, i32 -64 168 %v = load i32, ptr %a 169 ret i32 %v 170} 171 172define i64 @test16(ptr %p) { 173; CHECK-LABEL: 'test16' 174; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %a = getelementptr inbounds i64, ptr %p, i32 -64 175; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v = load i64, ptr %a, align 8 176; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret i64 %v 177; 178 %a = getelementptr inbounds i64, ptr %p, i32 -64 179 %v = load i64, ptr %a 180 ret i64 %v 181} 182 183define i8 @test17(ptr %p) { 184; CHECK-LABEL: 'test17' 185; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %a = getelementptr inbounds i8, ptr %p, i32 -1024 186; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v = load i8, ptr %a, align 1 187; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret i8 %v 188; 189 %a = getelementptr inbounds i8, ptr %p, i32 -1024 190 %v = load i8, ptr %a 191 ret i8 %v 192} 193 194define i16 @test18(ptr %p) { 195; CHECK-LABEL: 'test18' 196; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %a = getelementptr inbounds i16, ptr %p, i32 -1024 197; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v = load i16, ptr %a, align 2 198; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret i16 %v 199; 200 %a = getelementptr inbounds i16, ptr %p, i32 -1024 201 %v = load i16, ptr %a 202 ret i16 %v 203} 204 205define i32 @test19(ptr %p) { 206; CHECK-LABEL: 'test19' 207; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %a = getelementptr inbounds i32, ptr %p, i32 -1024 208; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v = load i32, ptr %a, align 4 209; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret i32 %v 210; 211 %a = getelementptr inbounds i32, ptr %p, i32 -1024 212 %v = load i32, ptr %a 213 ret i32 %v 214} 215 216define i64 @test20(ptr %p) { 217; CHECK-LABEL: 'test20' 218; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %a = getelementptr inbounds i64, ptr %p, i32 -1024 219; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v = load i64, ptr %a, align 8 220; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret i64 %v 221; 222 %a = getelementptr inbounds i64, ptr %p, i32 -1024 223 %v = load i64, ptr %a 224 ret i64 %v 225} 226 227define i8 @test21(ptr %p, i32 %i) { 228; CHECK-LABEL: 'test21' 229; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %a = getelementptr inbounds i8, ptr %p, i32 %i 230; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v = load i8, ptr %a, align 1 231; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret i8 %v 232; 233 %a = getelementptr inbounds i8, ptr %p, i32 %i 234 %v = load i8, ptr %a 235 ret i8 %v 236} 237 238define i16 @test22(ptr %p, i32 %i) { 239; CHECK-LABEL: 'test22' 240; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %a = getelementptr inbounds i16, ptr %p, i32 %i 241; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v = load i16, ptr %a, align 2 242; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret i16 %v 243; 244 %a = getelementptr inbounds i16, ptr %p, i32 %i 245 %v = load i16, ptr %a 246 ret i16 %v 247} 248 249define i32 @test23(ptr %p, i32 %i) { 250; CHECK-LABEL: 'test23' 251; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %a = getelementptr inbounds i32, ptr %p, i32 %i 252; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v = load i32, ptr %a, align 4 253; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret i32 %v 254; 255 %a = getelementptr inbounds i32, ptr %p, i32 %i 256 %v = load i32, ptr %a 257 ret i32 %v 258} 259 260define i64 @test24(ptr %p, i32 %i) { 261; CHECK-LABEL: 'test24' 262; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %a = getelementptr inbounds i64, ptr %p, i32 %i 263; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v = load i64, ptr %a, align 8 264; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret i64 %v 265; 266 %a = getelementptr inbounds i64, ptr %p, i32 %i 267 %v = load i64, ptr %a 268 ret i64 %v 269} 270 271define i8 @test25(ptr %p) { 272; CHECK-LABEL: 'test25' 273; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %a = getelementptr inbounds i8, ptr %p, i32 -128 274; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v = load i8, ptr %a, align 1 275; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret i8 %v 276; 277 %a = getelementptr inbounds i8, ptr %p, i32 -128 278 %v = load i8, ptr %a 279 ret i8 %v 280} 281 282define i16 @test26(ptr %p) { 283; CHECK-LABEL: 'test26' 284; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %a = getelementptr inbounds i16, ptr %p, i32 -128 285; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v = load i16, ptr %a, align 2 286; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret i16 %v 287; 288 %a = getelementptr inbounds i16, ptr %p, i32 -128 289 %v = load i16, ptr %a 290 ret i16 %v 291} 292 293define i32 @test27(ptr %p) { 294; CHECK-LABEL: 'test27' 295; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %a = getelementptr inbounds i32, ptr %p, i32 -128 296; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v = load i32, ptr %a, align 4 297; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret i32 %v 298; 299 %a = getelementptr inbounds i32, ptr %p, i32 -128 300 %v = load i32, ptr %a 301 ret i32 %v 302} 303 304define i64 @test28(ptr %p) { 305; CHECK-LABEL: 'test28' 306; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %a = getelementptr inbounds i64, ptr %p, i32 -128 307; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v = load i64, ptr %a, align 8 308; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret i64 %v 309; 310 %a = getelementptr inbounds i64, ptr %p, i32 -128 311 %v = load i64, ptr %a 312 ret i64 %v 313} 314 315define i8 @test29(ptr %p) { 316; CHECK-LABEL: 'test29' 317; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %a = getelementptr inbounds i8, ptr %p, i32 -256 318; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v = load i8, ptr %a, align 1 319; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret i8 %v 320; 321 %a = getelementptr inbounds i8, ptr %p, i32 -256 322 %v = load i8, ptr %a 323 ret i8 %v 324} 325 326define i16 @test30(ptr %p) { 327; CHECK-LABEL: 'test30' 328; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %a = getelementptr inbounds i16, ptr %p, i32 -256 329; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v = load i16, ptr %a, align 2 330; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret i16 %v 331; 332 %a = getelementptr inbounds i16, ptr %p, i32 -256 333 %v = load i16, ptr %a 334 ret i16 %v 335} 336 337define i32 @test31(ptr %p) { 338; CHECK-LABEL: 'test31' 339; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %a = getelementptr inbounds i32, ptr %p, i32 -256 340; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v = load i32, ptr %a, align 4 341; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret i32 %v 342; 343 %a = getelementptr inbounds i32, ptr %p, i32 -256 344 %v = load i32, ptr %a 345 ret i32 %v 346} 347 348define i64 @test32(ptr %p) { 349; CHECK-LABEL: 'test32' 350; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %a = getelementptr inbounds i64, ptr %p, i32 -256 351; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v = load i64, ptr %a, align 8 352; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret i64 %v 353; 354 %a = getelementptr inbounds i64, ptr %p, i32 -256 355 %v = load i64, ptr %a 356 ret i64 %v 357} 358 359define i8 @test33(ptr %p) { 360; CHECK-LABEL: 'test33' 361; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %a = getelementptr inbounds i8, ptr %p, i32 -512 362; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v = load i8, ptr %a, align 1 363; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret i8 %v 364; 365 %a = getelementptr inbounds i8, ptr %p, i32 -512 366 %v = load i8, ptr %a 367 ret i8 %v 368} 369 370define i16 @test34(ptr %p) { 371; CHECK-LABEL: 'test34' 372; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %a = getelementptr inbounds i16, ptr %p, i32 -512 373; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v = load i16, ptr %a, align 2 374; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret i16 %v 375; 376 %a = getelementptr inbounds i16, ptr %p, i32 -512 377 %v = load i16, ptr %a 378 ret i16 %v 379} 380 381define i32 @test35(ptr %p) { 382; CHECK-LABEL: 'test35' 383; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %a = getelementptr inbounds i32, ptr %p, i32 -512 384; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v = load i32, ptr %a, align 4 385; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret i32 %v 386; 387 %a = getelementptr inbounds i32, ptr %p, i32 -512 388 %v = load i32, ptr %a 389 ret i32 %v 390} 391 392define i64 @test36(ptr %p) { 393; CHECK-LABEL: 'test36' 394; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %a = getelementptr inbounds i64, ptr %p, i32 -512 395; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v = load i64, ptr %a, align 8 396; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret i64 %v 397; 398 %a = getelementptr inbounds i64, ptr %p, i32 -512 399 %v = load i64, ptr %a 400 ret i64 %v 401} 402