brintos

brintos / llvm-project-archived public Read only

0
0
Text · 11.8 KiB · 6c791f1 Raw
233 lines · plain
1// RUN: fir-opt %s --test-side-effects --verify-diagnostics2 3func.func @concat(%arg0: !fir.ref<!fir.char<1,10>>, %arg1: !fir.ref<!fir.char<1, 20>>) {4// expected-remark@+1 {{operation has no memory effects}}5  %c30 = arith.constant 30 : index6// expected-remark@+3 {{found an instance of 'allocate' on op result 0, on resource '<Default>'}}7// expected-remark@+2 {{found an instance of 'read' on op operand 0, on resource '<Default>'}}8// expected-remark@+1 {{found an instance of 'read' on op operand 1, on resource '<Default>'}}9  %0 = hlfir.concat %arg0, %arg1 len %c30 : (!fir.ref<!fir.char<1,10>>, !fir.ref<!fir.char<1,20>>, index) -> (!hlfir.expr<!fir.char<1,30>>)10  return11}12 13func.func @all_no_effects(%arg0: !hlfir.expr<2x!fir.logical<4>>) {14// expected-remark@+1 {{operation has no memory effects}}15  %all = hlfir.all %arg0 : (!hlfir.expr<2x!fir.logical<4>>) -> !fir.logical<4>16  return17}18 19func.func @all_effects(%arg0: !fir.ref<!fir.array<2x10x!fir.logical<4>>>, %arg1: i32) {20// expected-remark@+2 {{found an instance of 'allocate' on op result 0, on resource '<Default>'}}21// expected-remark@+1 {{found an instance of 'read' on op operand 0, on resource '<Default>'}}22  %all = hlfir.all %arg0 dim %arg1 : (!fir.ref<!fir.array<2x10x!fir.logical<4>>>, i32) -> !hlfir.expr<?x!fir.logical<4>>23  return24}25 26func.func @any_no_effects(%arg0: !hlfir.expr<2x!fir.logical<4>>) {27// expected-remark@+1 {{operation has no memory effects}}28  %all = hlfir.any %arg0 : (!hlfir.expr<2x!fir.logical<4>>) -> !fir.logical<4>29  return30}31 32func.func @any_effects(%arg0: !fir.ref<!fir.array<2x10x!fir.logical<4>>>, %arg1: i32) {33// expected-remark@+2 {{found an instance of 'allocate' on op result 0, on resource '<Default>'}}34// expected-remark@+1 {{found an instance of 'read' on op operand 0, on resource '<Default>'}}35  %all = hlfir.any %arg0 dim %arg1 : (!fir.ref<!fir.array<2x10x!fir.logical<4>>>, i32) -> !hlfir.expr<?x!fir.logical<4>>36  return37}38 39func.func @count_no_effects(%arg0: !hlfir.expr<2x!fir.logical<4>>) {40// expected-remark@+1 {{operation has no memory effects}}41  %all = hlfir.count %arg0 : (!hlfir.expr<2x!fir.logical<4>>) -> i3242  return43}44 45func.func @count_effects(%arg0: !fir.ref<!fir.array<2x10x!fir.logical<4>>>, %arg1: i32) {46// expected-remark@+1 {{found an instance of 'read' on op operand 0, on resource '<Default>'}}47  %all = hlfir.count %arg0 dim %arg1 : (!fir.ref<!fir.array<2x10x!fir.logical<4>>>, i32) -> i3248  return49}50 51func.func @product_no_effects(%arg0: !hlfir.expr<?xf32>) {52// expected-remark@+1 {{operation has no memory effects}}53  %product = hlfir.product %arg0 : (!hlfir.expr<?xf32>) -> f3254  return55}56 57func.func @product_effects(%arg0: !fir.ref<!fir.array<2x2xf32>>, %arg1: i32) {58// expected-remark@+2 {{found an instance of 'allocate' on op result 0, on resource '<Default>'}}59// expected-remark@+1 {{found an instance of 'read' on op operand 0, on resource '<Default>'}}60  %product = hlfir.product %arg0 dim %arg1 : (!fir.ref<!fir.array<2x2xf32>>, i32) -> !hlfir.expr<2xf32>61  return62}63 64func.func @set_length_read(%arg0: !fir.ref<!fir.char<1,10>>, %arg1: index) {65// expected-remark@+2 {{found an instance of 'allocate' on op result 0, on resource '<Default>'}}66// expected-remark@+1 {{found an instance of 'read' on op operand 0, on resource '<Default>'}}67  %0 = hlfir.set_length %arg0 len %arg1 : (!fir.ref<!fir.char<1,10>>, index) -> !hlfir.expr<!fir.char<1,?>>68  return69}70 71func.func @sum_no_effects(%arg0: !hlfir.expr<?xf32>) {72// expected-remark@+1 {{operation has no memory effects}}73  %sum = hlfir.sum %arg0 : (!hlfir.expr<?xf32>) -> f3274  return75}76 77func.func @sum_effects(%arg0: !fir.ref<!fir.array<2x2xf32>>, %arg1: i32) {78// expected-remark@+2 {{found an instance of 'allocate' on op result 0, on resource '<Default>'}}79// expected-remark@+1 {{found an instance of 'read' on op operand 0, on resource '<Default>'}}80  %sum = hlfir.sum %arg0 dim %arg1 : (!fir.ref<!fir.array<2x2xf32>>, i32) -> !hlfir.expr<2xf32>81  return82}83 84func.func @maxval_no_effects(%arg0: !hlfir.expr<?xf32>) {85// expected-remark@+1 {{operation has no memory effects}}86  %maxval = hlfir.maxval %arg0 : (!hlfir.expr<?xf32>) -> f3287  return88}89 90func.func @maxval_effects(%arg0: !fir.ref<!fir.array<2x2xf32>>, %arg1: i32) {91// expected-remark@+2 {{found an instance of 'allocate' on op result 0, on resource '<Default>'}}92// expected-remark@+1 {{found an instance of 'read' on op operand 0, on resource '<Default>'}}93  %maxval = hlfir.maxval %arg0 dim %arg1 : (!fir.ref<!fir.array<2x2xf32>>, i32) -> !hlfir.expr<2xf32>94  return95}96 97func.func @minval_no_effects(%arg0: !hlfir.expr<?xf32>) {98// expected-remark@+1 {{operation has no memory effects}}99  %minval = hlfir.minval %arg0 : (!hlfir.expr<?xf32>) -> f32100  return101}102 103func.func @minval_effects(%arg0: !fir.ref<!fir.array<2x2xf32>>, %arg1: i32) {104// expected-remark@+2 {{found an instance of 'allocate' on op result 0, on resource '<Default>'}}105// expected-remark@+1 {{found an instance of 'read' on op operand 0, on resource '<Default>'}}106  %minval = hlfir.minval %arg0 dim %arg1 : (!fir.ref<!fir.array<2x2xf32>>, i32) -> !hlfir.expr<2xf32>107  return108}109 110func.func @minloc_effects_simple(%arg0: !hlfir.expr<?xf32>) {111// expected-remark@+1 {{found an instance of 'allocate' on op result 0, on resource '<Default>'}}112  %minloc = hlfir.minloc %arg0 : (!hlfir.expr<?xf32>) -> !hlfir.expr<?xi32>113  return114}115 116func.func @minloc_effects(%arg0: !fir.ref<!fir.array<2x2xf32>>, %arg1: i32) {117// expected-remark@+2 {{found an instance of 'allocate' on op result 0, on resource '<Default>'}}118// expected-remark@+1 {{found an instance of 'read' on op operand 0, on resource '<Default>'}}119  %minloc = hlfir.minloc %arg0 dim %arg1 : (!fir.ref<!fir.array<2x2xf32>>, i32) -> !hlfir.expr<2xi32>120  return121}122 123func.func @maxloc_effects_simple(%arg0: !hlfir.expr<?xf32>) {124// expected-remark@+1 {{found an instance of 'allocate' on op result 0, on resource '<Default>'}}125  %maxloc = hlfir.maxloc %arg0 : (!hlfir.expr<?xf32>) -> !hlfir.expr<?xi32>126  return127}128 129func.func @maxloc_effects(%arg0: !fir.ref<!fir.array<2x2xf32>>, %arg1: i32) {130// expected-remark@+2 {{found an instance of 'allocate' on op result 0, on resource '<Default>'}}131// expected-remark@+1 {{found an instance of 'read' on op operand 0, on resource '<Default>'}}132  %maxloc = hlfir.maxloc %arg0 dim %arg1 : (!fir.ref<!fir.array<2x2xf32>>, i32) -> !hlfir.expr<2xi32>133  return134}135 136func.func @dot_product_no_effects(%arg0: !hlfir.expr<?xf32>, %arg1: !hlfir.expr<?xf32>) {137// expected-remark@+1 {{operation has no memory effects}}138  %0 = hlfir.dot_product %arg0 %arg1 : (!hlfir.expr<?xf32>, !hlfir.expr<?xf32>) -> f32139  return140}141 142func.func @dot_product_effects(%arg0: !fir.ref<!fir.array<10xf32>>, %arg1: !fir.ref<!fir.array<10xf32>>) {143// expected-remark@+2 {{found an instance of 'read' on op operand 0, on resource '<Default>'}}144// expected-remark@+1 {{found an instance of 'read' on op operand 1, on resource '<Default>'}}145  %0 = hlfir.dot_product %arg0 %arg1 : (!fir.ref<!fir.array<10xf32>>, !fir.ref<!fir.array<10xf32>>) -> f32146  return147}148 149func.func @matmul_no_reads(%arg0: !hlfir.expr<?x?xf32>, %arg1: !hlfir.expr<?x?xf32>) {150// expected-remark@+1 {{found an instance of 'allocate' on op result 0, on resource '<Default>'}}151  %0 = hlfir.matmul %arg0 %arg1 : (!hlfir.expr<?x?xf32>, !hlfir.expr<?x?xf32>) -> !hlfir.expr<?x?xf32>152  return153}154 155func.func @matmul_reads(%arg0: !fir.ref<!fir.array<10x5xf32>>, %arg1: !fir.ref<!fir.array<5x10xf32>>) {156// expected-remark@+3 {{found an instance of 'allocate' on op result 0, on resource '<Default>'}}157// expected-remark@+2 {{found an instance of 'read' on op operand 0, on resource '<Default>'}}158// expected-remark@+1 {{found an instance of 'read' on op operand 1, on resource '<Default>'}}159  %0 = hlfir.matmul %arg0 %arg1 : (!fir.ref<!fir.array<10x5xf32>>, !fir.ref<!fir.array<5x10xf32>>) -> !hlfir.expr<10x10xf32>160  return161}162 163func.func @transpose_no_reads(%arg0: !hlfir.expr<?x?xf32>) {164// expected-remark@+1 {{found an instance of 'allocate' on op result 0, on resource '<Default>'}}165  %0 = hlfir.transpose %arg0 : (!hlfir.expr<?x?xf32>) -> !hlfir.expr<?x?xf32>166  return167}168 169func.func @transpose_read(%arg0: !fir.ref<!fir.array<10x5xf32>>) {170// expected-remark@+2 {{found an instance of 'allocate' on op result 0, on resource '<Default>'}}171// expected-remark@+1 {{found an instance of 'read' on op operand 0, on resource '<Default>'}}172  %0 = hlfir.transpose %arg0 : (!fir.ref<!fir.array<10x5xf32>>) -> !hlfir.expr<5x10xf32>173  return174}175 176func.func @matmul_transpose_no_reads(%arg0: !hlfir.expr<?x?xf32>, %arg1: !hlfir.expr<?x?xf32>) {177// expected-remark@+1 {{found an instance of 'allocate' on op result 0, on resource '<Default>'}}178  %0 = hlfir.matmul_transpose %arg0 %arg1 : (!hlfir.expr<?x?xf32>, !hlfir.expr<?x?xf32>) -> !hlfir.expr<?x?xf32>179  return180}181 182func.func @matmul_transpose_reads(%arg0: !fir.ref<!fir.array<5x10xf32>>, %arg1: !fir.ref<!fir.array<5x10xf32>>) {183// expected-remark@+3 {{found an instance of 'allocate' on op result 0, on resource '<Default>'}}184// expected-remark@+2 {{found an instance of 'read' on op operand 0, on resource '<Default>'}}185// expected-remark@+1 {{found an instance of 'read' on op operand 1, on resource '<Default>'}}186  %0 = hlfir.matmul_transpose %arg0 %arg1 : (!fir.ref<!fir.array<5x10xf32>>, !fir.ref<!fir.array<5x10xf32>>) -> !hlfir.expr<10x10xf32>187  return188}189 190func.func @associate(%arg0: i32) {191// expected-remark@+1 {{found an instance of 'allocate' on resource '<Default>'}}192  %0:3 = hlfir.associate %arg0 {uniq_name = "x"} : (i32) -> (!fir.ref<i32>, !fir.ref<i32>, i1)193// expected-remark@+1 {{found an instance of 'free' on resource '<Default>'}}194  hlfir.end_associate %0#1, %0#2 : !fir.ref<i32>, i1195  return196}197 198func.func @as_expr_read(%arg0: !fir.ref<!fir.array<2xi32>>) {199// expected-remark@+2 {{found an instance of 'allocate' on op result 0, on resource '<Default>'}}200// expected-remark@+1 {{found an instance of 'read' on op operand 0, on resource '<Default>'}}201  %0 = hlfir.as_expr %arg0 : (!fir.ref<!fir.array<2xi32>>) -> !hlfir.expr<?xi32>202// expected-remark@+1 {{found an instance of 'free' on resource '<Default>'}}203  hlfir.destroy %0 : !hlfir.expr<?xi32>204  return205}206 207func.func @char_extremum(%arg0: !fir.ref<!fir.char<1,10>>, %arg1: !fir.ref<!fir.char<1,20>>) {208// expected-remark@+3 {{found an instance of 'allocate' on op result 0, on resource '<Default>'}}209// expected-remark@+2 {{found an instance of 'read' on op operand 0, on resource '<Default>'}}210// expected-remark@+1 {{found an instance of 'read' on op operand 1, on resource '<Default>'}}211  %0 = hlfir.char_extremum min, %arg0, %arg1 : (!fir.ref<!fir.char<1, 10>>, !fir.ref<!fir.char<1,20>>) -> !hlfir.expr<!fir.char<1,10>>212  return213}214 215func.func @copy_in(%box: !fir.box<!fir.array<?xf64>>, %temp: !fir.ref<!fir.box<!fir.heap<!fir.array<?xf64>>>>, %is_present: i1) {216// expected-remark@+3 {{found an instance of 'allocate' on resource '<Default>'}}217// expected-remark@+2 {{found an instance of 'read' on op operand 0, on resource '<Default>'}}218// expected-remark@+1 {{found an instance of 'write' on op operand 1, on resource '<Default>'}}219  %0:2 = hlfir.copy_in %box to %temp : (!fir.box<!fir.array<?xf64>>, !fir.ref<!fir.box<!fir.heap<!fir.array<?xf64>>>>) -> (!fir.box<!fir.array<?xf64>>, i1)220  return221}222 223func.func @copy_out(%box: !fir.box<!fir.array<?xf64>>, %temp: !fir.ref<!fir.box<!fir.heap<!fir.array<?xf64>>>>, %was_copied: i1) {224// expected-remark@+2 {{found an instance of 'free' on resource '<Default>'}}225// expected-remark@+1 {{found an instance of 'read' on op operand 0, on resource '<Default>'}}226  hlfir.copy_out %temp, %was_copied : (!fir.ref<!fir.box<!fir.heap<!fir.array<?xf64>>>>, i1) -> ()227// expected-remark@+3 {{found an instance of 'free' on resource '<Default>'}}228// expected-remark@+2 {{found an instance of 'read' on op operand 0, on resource '<Default>'}}229// expected-remark@+1 {{found an instance of 'write' on op operand 2, on resource '<Default>'}}230  hlfir.copy_out %temp, %was_copied to %box : (!fir.ref<!fir.box<!fir.heap<!fir.array<?xf64>>>>, i1, !fir.box<!fir.array<?xf64>>) -> ()231  return232}233