103 lines · plain
1; NOTE: Assertions have been autogenerated by utils/update_analyze_test_checks.py UTC_ARGS: --version 22; RUN: opt -mtriple=riscv32 -mattr=+v -passes="print<cost-model>" 2>&1 -disable-output < %s \3; RUN: | FileCheck %s4; RUN: opt -mtriple=riscv64 -mattr=+v -passes="print<cost-model>" 2>&1 -disable-output < %s \5; RUN: | FileCheck %s6 7; These GEPs should all cost zero becuase all the indices operands are zero, so8; no computation actually needs to happen.9 10define ptr @zero_indices_i8(ptr %p) {11; CHECK-LABEL: 'zero_indices_i8'12; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %x = getelementptr i8, ptr %p, i32 013; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret ptr %x14;15 %x = getelementptr i8, ptr %p, i32 016 ret ptr %x17}18 19define ptr @zero_indices_i16(ptr %p) {20; CHECK-LABEL: 'zero_indices_i16'21; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %x = getelementptr i16, ptr %p, i32 022; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret ptr %x23;24 %x = getelementptr i16, ptr %p, i32 025 ret ptr %x26}27 28define ptr @zero_indices_i32(ptr %p) {29; CHECK-LABEL: 'zero_indices_i32'30; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %x = getelementptr i32, ptr %p, i32 031; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret ptr %x32;33 %x = getelementptr i32, ptr %p, i32 034 ret ptr %x35}36 37define ptr @zero_indices_i64(ptr %p) {38; CHECK-LABEL: 'zero_indices_i64'39; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %x = getelementptr i64, ptr %p, i32 040; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret ptr %x41;42 %x = getelementptr i64, ptr %p, i32 043 ret ptr %x44}45 46define ptr @zero_indices_array(ptr %p) {47; CHECK-LABEL: 'zero_indices_array'48; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %x = getelementptr [42 x i64], ptr %p, i32 0, i32 049; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret ptr %x50;51 %x = getelementptr [42 x i64], ptr %p, i32 0, i32 052 ret ptr %x53}54 55%struct = type { %struct.inner }56%struct.inner = type { %struct.inner.inner }57%struct.inner.inner = type { i32 }58 59define ptr @zero_indices_struct(ptr %p) {60; CHECK-LABEL: 'zero_indices_struct'61; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %x = getelementptr %struct, ptr %p, i32 0, i32 0, i32 062; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret ptr %x63;64 %x = getelementptr %struct, ptr %p, i32 0, i32 0, i32 065 ret ptr %x66}67 68define <4 x ptr> @zero_indices_v4i32(<4 x ptr> %p) {69; CHECK-LABEL: 'zero_indices_v4i32'70; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %x = getelementptr i32, <4 x ptr> %p, <4 x i32> zeroinitializer71; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret <4 x ptr> %x72;73 %x = getelementptr i32, <4 x ptr> %p, <4 x i32> zeroinitializer74 ret <4 x ptr> %x75}76 77define <16 x ptr> @zero_indices_v16i32(<16 x ptr> %p) {78; CHECK-LABEL: 'zero_indices_v16i32'79; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %x = getelementptr i32, <16 x ptr> %p, <16 x i32> zeroinitializer80; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret <16 x ptr> %x81;82 %x = getelementptr i32, <16 x ptr> %p, <16 x i32> zeroinitializer83 ret <16 x ptr> %x84}85 86define <4 x ptr> @zero_indices_v4f32(<4 x ptr> %p) {87; CHECK-LABEL: 'zero_indices_v4f32'88; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %x = getelementptr float, <4 x ptr> %p, <4 x i32> zeroinitializer89; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret <4 x ptr> %x90;91 %x = getelementptr float, <4 x ptr> %p, <4 x i32> zeroinitializer92 ret <4 x ptr> %x93}94 95define <4 x ptr> @zero_indices_v4v4i32(<4 x ptr> %p) {96; CHECK-LABEL: 'zero_indices_v4v4i32'97; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %x = getelementptr <32 x i32>, <4 x ptr> %p, <4 x i32> zeroinitializer, <4 x i32> zeroinitializer98; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret <4 x ptr> %x99;100 %x = getelementptr <32 x i32>, <4 x ptr> %p, <4 x i32> zeroinitializer, <4 x i32> zeroinitializer101 ret <4 x ptr> %x102}103