351 lines · plain
1// RUN: mlir-opt -test-last-modified %s 2>&1 | FileCheck %s2 3// CHECK-LABEL: test_tag: test_simple_mod4// CHECK: operand #05// CHECK-NEXT: - a6// CHECK: operand #17// CHECK-NEXT: - b8func.func @test_simple_mod(%arg0: memref<i32>, %arg1: memref<i32>) -> (memref<i32>, memref<i32>) {9 %c0 = arith.constant 0 : i3210 %c1 = arith.constant 1 : i3211 memref.store %c0, %arg0[] {tag_name = "a"} : memref<i32>12 memref.store %c1, %arg1[] {tag_name = "b"} : memref<i32>13 return {tag = "test_simple_mod"} %arg0, %arg1 : memref<i32>, memref<i32>14}15 16// CHECK-LABEL: test_tag: test_simple_mod_overwrite_a17// CHECK: operand #118// CHECK-NEXT: - a19// CHECK-LABEL: test_tag: test_simple_mod_overwrite_b20// CHECK: operand #021// CHECK-NEXT: - b22func.func @test_simple_mod_overwrite(%arg0: memref<i32>) -> memref<i32> {23 %c0 = arith.constant 0 : i3224 memref.store %c0, %arg0[] {tag = "test_simple_mod_overwrite_a", tag_name = "a"} : memref<i32>25 %c1 = arith.constant 1 : i3226 memref.store %c1, %arg0[] {tag_name = "b"} : memref<i32>27 return {tag = "test_simple_mod_overwrite_b"} %arg0 : memref<i32>28}29 30// CHECK-LABEL: test_tag: test_mod_control_flow31// CHECK: operand #032// CHECK-NEXT: - b33// CHECK-NEXT: - a34func.func @test_mod_control_flow(%cond: i1, %ptr: memref<i32>) -> memref<i32> {35 cf.cond_br %cond, ^a, ^b36 37^a:38 %c0 = arith.constant 0 : i3239 memref.store %c0, %ptr[] {tag_name = "a"} : memref<i32>40 cf.br ^c41 42^b:43 %c1 = arith.constant 1 : i3244 memref.store %c1, %ptr[] {tag_name = "b"} : memref<i32>45 cf.br ^c46 47^c:48 return {tag = "test_mod_control_flow"} %ptr : memref<i32>49}50 51// CHECK-LABEL: test_tag: test_mod_dead_branch52// CHECK: operand #053// CHECK-NEXT: - a54func.func @test_mod_dead_branch(%arg: i32, %ptr: memref<i32>) -> memref<i32> {55 %0 = arith.subi %arg, %arg : i3256 %1 = arith.constant -1 : i3257 %2 = arith.cmpi sgt, %0, %1 : i3258 cf.cond_br %2, ^a, ^b59 60^a:61 %c0 = arith.constant 0 : i3262 memref.store %c0, %ptr[] {tag_name = "a"} : memref<i32>63 cf.br ^c64 65^b:66 %c1 = arith.constant 1 : i3267 memref.store %c1, %ptr[] {tag_name = "b"} : memref<i32>68 cf.br ^c69 70^c:71 return {tag = "test_mod_dead_branch"} %ptr : memref<i32>72}73 74// CHECK-LABEL: test_tag: test_mod_region_control_flow75// CHECK: operand #076// CHECK-NEXT: then77// CHECK-NEXT: else78func.func @test_mod_region_control_flow(%cond: i1, %ptr: memref<i32>) -> memref<i32> {79 scf.if %cond {80 %c0 = arith.constant 0 : i3281 memref.store %c0, %ptr[] {tag_name = "then"}: memref<i32>82 } else {83 %c1 = arith.constant 1 : i3284 memref.store %c1, %ptr[] {tag_name = "else"} : memref<i32>85 }86 return {tag = "test_mod_region_control_flow"} %ptr : memref<i32>87}88 89// CHECK-LABEL: test_tag: test_mod_dead_region90// CHECK: operand #091// CHECK-NEXT: else92func.func @test_mod_dead_region(%ptr: memref<i32>) -> memref<i32> {93 %false = arith.constant false94 scf.if %false {95 %c0 = arith.constant 0 : i3296 memref.store %c0, %ptr[] {tag_name = "then"}: memref<i32>97 } else {98 %c1 = arith.constant 1 : i3299 memref.store %c1, %ptr[] {tag_name = "else"} : memref<i32>100 }101 return {tag = "test_mod_dead_region"} %ptr : memref<i32>102}103 104// CHECK-LABEL: test_tag: unknown_memory_effects_a105// CHECK: operand #1106// CHECK-NEXT: - a107// CHECK-LABEL: test_tag: unknown_memory_effects_b108// CHECK: operand #0109// CHECK-NEXT: - <unknown>110func.func @unknown_memory_effects(%ptr: memref<i32>) -> memref<i32> {111 %c0 = arith.constant 0 : i32112 memref.store %c0, %ptr[] {tag = "unknown_memory_effects_a", tag_name = "a"} : memref<i32>113 "test.unknown_effects"() : () -> ()114 return {tag = "unknown_memory_effects_b"} %ptr : memref<i32>115}116 117// CHECK-LABEL: test_tag: store_with_a_region_before::before:118// CHECK: operand #0119// CHECK: - pre120// CHECK: test_tag: inside_region:121// CHECK: operand #0122// CHECK: - region123// CHECK: test_tag: after:124// CHECK: operand #0125// CHECK: - region126// CHECK: test_tag: return:127// CHECK: operand #0128// CHECK: - post129func.func @store_with_a_region_before(%arg0: memref<f32>) -> memref<f32> {130 %0 = arith.constant 0.0 : f32131 %1 = arith.constant 1.0 : f32132 memref.store %0, %arg0[] {tag_name = "pre"} : memref<f32>133 memref.load %arg0[] {tag = "store_with_a_region_before::before"} : memref<f32>134 test.store_with_a_region %arg0 attributes { tag_name = "region", store_before_region = true } {135 memref.load %arg0[] {tag = "inside_region"} : memref<f32>136 test.store_with_a_region_terminator137 } : memref<f32>138 memref.load %arg0[] {tag = "after"} : memref<f32>139 memref.store %1, %arg0[] {tag_name = "post"} : memref<f32>140 return {tag = "return"} %arg0 : memref<f32>141}142 143// CHECK-LABEL: test_tag: store_with_a_region_after::before:144// CHECK: operand #0145// CHECK: - pre146// CHECK: test_tag: inside_region:147// CHECK: operand #0148// CHECK: - pre149// CHECK: test_tag: after:150// CHECK: operand #0151// CHECK: - region152// CHECK: test_tag: return:153// CHECK: operand #0154// CHECK: - post155func.func @store_with_a_region_after(%arg0: memref<f32>) -> memref<f32> {156 %0 = arith.constant 0.0 : f32157 %1 = arith.constant 1.0 : f32158 memref.store %0, %arg0[] {tag_name = "pre"} : memref<f32>159 memref.load %arg0[] {tag = "store_with_a_region_after::before"} : memref<f32>160 test.store_with_a_region %arg0 attributes { tag_name = "region", store_before_region = false } {161 memref.load %arg0[] {tag = "inside_region"} : memref<f32>162 test.store_with_a_region_terminator163 } : memref<f32>164 memref.load %arg0[] {tag = "after"} : memref<f32>165 memref.store %1, %arg0[] {tag_name = "post"} : memref<f32>166 return {tag = "return"} %arg0 : memref<f32>167}168 169// CHECK-LABEL: test_tag: store_with_a_region_before_containing_a_store::before:170// CHECK: operand #0171// CHECK: - pre172// CHECK: test_tag: enter_region:173// CHECK: operand #0174// CHECK: - region175// CHECK: test_tag: exit_region:176// CHECK: operand #0177// CHECK: - inner178// CHECK: test_tag: after:179// CHECK: operand #0180// CHECK: - inner181// CHECK: test_tag: return:182// CHECK: operand #0183// CHECK: - post184func.func @store_with_a_region_before_containing_a_store(%arg0: memref<f32>) -> memref<f32> {185 %0 = arith.constant 0.0 : f32186 %1 = arith.constant 1.0 : f32187 memref.store %0, %arg0[] {tag_name = "pre"} : memref<f32>188 memref.load %arg0[] {tag = "store_with_a_region_before_containing_a_store::before"} : memref<f32>189 test.store_with_a_region %arg0 attributes { tag_name = "region", store_before_region = true } {190 memref.load %arg0[] {tag = "enter_region"} : memref<f32>191 %2 = arith.constant 2.0 : f32192 memref.store %2, %arg0[] {tag_name = "inner"} : memref<f32>193 memref.load %arg0[] {tag = "exit_region"} : memref<f32>194 test.store_with_a_region_terminator195 } : memref<f32>196 memref.load %arg0[] {tag = "after"} : memref<f32>197 memref.store %1, %arg0[] {tag_name = "post"} : memref<f32>198 return {tag = "return"} %arg0 : memref<f32>199}200 201// CHECK-LABEL: test_tag: store_with_a_region_after_containing_a_store::before:202// CHECK: operand #0203// CHECK: - pre204// CHECK: test_tag: enter_region:205// CHECK: operand #0206// CHECK: - pre207// CHECK: test_tag: exit_region:208// CHECK: operand #0209// CHECK: - inner210// CHECK: test_tag: after:211// CHECK: operand #0212// CHECK: - region213// CHECK: test_tag: return:214// CHECK: operand #0215// CHECK: - post216func.func @store_with_a_region_after_containing_a_store(%arg0: memref<f32>) -> memref<f32> {217 %0 = arith.constant 0.0 : f32218 %1 = arith.constant 1.0 : f32219 memref.store %0, %arg0[] {tag_name = "pre"} : memref<f32>220 memref.load %arg0[] {tag = "store_with_a_region_after_containing_a_store::before"} : memref<f32>221 test.store_with_a_region %arg0 attributes { tag_name = "region", store_before_region = false } {222 memref.load %arg0[] {tag = "enter_region"} : memref<f32>223 %2 = arith.constant 2.0 : f32224 memref.store %2, %arg0[] {tag_name = "inner"} : memref<f32>225 memref.load %arg0[] {tag = "exit_region"} : memref<f32>226 test.store_with_a_region_terminator227 } : memref<f32>228 memref.load %arg0[] {tag = "after"} : memref<f32>229 memref.store %1, %arg0[] {tag_name = "post"} : memref<f32>230 return {tag = "return"} %arg0 : memref<f32>231}232 233// CHECK-LABEL: test_tag: store_with_a_loop_region_before::before:234// CHECK: operand #0235// CHECK: - pre236// CHECK: test_tag: inside_region:237// CHECK: operand #0238// CHECK: - region239// CHECK: test_tag: after:240// CHECK: operand #0241// CHECK: - region242// CHECK: test_tag: return:243// CHECK: operand #0244// CHECK: - post245func.func @store_with_a_loop_region_before(%arg0: memref<f32>) -> memref<f32> {246 %0 = arith.constant 0.0 : f32247 %1 = arith.constant 1.0 : f32248 memref.store %0, %arg0[] {tag_name = "pre"} : memref<f32>249 memref.load %arg0[] {tag = "store_with_a_loop_region_before::before"} : memref<f32>250 test.store_with_a_loop_region %arg0 attributes { tag_name = "region", store_before_region = true } {251 memref.load %arg0[] {tag = "inside_region"} : memref<f32>252 test.store_with_a_region_terminator253 } : memref<f32>254 memref.load %arg0[] {tag = "after"} : memref<f32>255 memref.store %1, %arg0[] {tag_name = "post"} : memref<f32>256 return {tag = "return"} %arg0 : memref<f32>257}258 259// CHECK-LABEL: test_tag: store_with_a_loop_region_after::before:260// CHECK: operand #0261// CHECK: - pre262// CHECK: test_tag: inside_region:263// CHECK: operand #0264// CHECK: - pre265// CHECK: test_tag: after:266// CHECK: operand #0267// CHECK: - region268// CHECK: test_tag: return:269// CHECK: operand #0270// CHECK: - post271func.func @store_with_a_loop_region_after(%arg0: memref<f32>) -> memref<f32> {272 %0 = arith.constant 0.0 : f32273 %1 = arith.constant 1.0 : f32274 memref.store %0, %arg0[] {tag_name = "pre"} : memref<f32>275 memref.load %arg0[] {tag = "store_with_a_loop_region_after::before"} : memref<f32>276 test.store_with_a_loop_region %arg0 attributes { tag_name = "region", store_before_region = false } {277 memref.load %arg0[] {tag = "inside_region"} : memref<f32>278 test.store_with_a_region_terminator279 } : memref<f32>280 memref.load %arg0[] {tag = "after"} : memref<f32>281 memref.store %1, %arg0[] {tag_name = "post"} : memref<f32>282 return {tag = "return"} %arg0 : memref<f32>283}284 285// CHECK-LABEL: test_tag: store_with_a_loop_region_before_containing_a_store::before:286// CHECK: operand #0287// CHECK: - pre288// CHECK: test_tag: enter_region:289// CHECK: operand #0290// CHECK-DAG: - region291// CHECK-DAG: - inner292// CHECK: test_tag: exit_region:293// CHECK: operand #0294// CHECK: - inner295// CHECK: test_tag: after:296// CHECK: operand #0297// CHECK-DAG: - region298// CHECK-DAG: - inner299// CHECK: test_tag: return:300// CHECK: operand #0301// CHECK: - post302func.func @store_with_a_loop_region_before_containing_a_store(%arg0: memref<f32>) -> memref<f32> {303 %0 = arith.constant 0.0 : f32304 %1 = arith.constant 1.0 : f32305 memref.store %0, %arg0[] {tag_name = "pre"} : memref<f32>306 memref.load %arg0[] {tag = "store_with_a_loop_region_before_containing_a_store::before"} : memref<f32>307 test.store_with_a_loop_region %arg0 attributes { tag_name = "region", store_before_region = true } {308 memref.load %arg0[] {tag = "enter_region"} : memref<f32>309 %2 = arith.constant 2.0 : f32310 memref.store %2, %arg0[] {tag_name = "inner"} : memref<f32>311 memref.load %arg0[] {tag = "exit_region"} : memref<f32>312 test.store_with_a_region_terminator313 } : memref<f32>314 memref.load %arg0[] {tag = "after"} : memref<f32>315 memref.store %1, %arg0[] {tag_name = "post"} : memref<f32>316 return {tag = "return"} %arg0 : memref<f32>317}318 319// CHECK-LABEL: test_tag: store_with_a_loop_region_after_containing_a_store::before:320// CHECK: operand #0321// CHECK: - pre322// CHECK: test_tag: enter_region:323// CHECK: operand #0324// CHECK-DAG: - pre325// CHECK-DAG: - inner326// CHECK: test_tag: exit_region:327// CHECK: operand #0328// CHECK: - inner329// CHECK: test_tag: after:330// CHECK: operand #0331// CHECK: - region332// CHECK: test_tag: return:333// CHECK: operand #0334// CHECK: - post335func.func @store_with_a_loop_region_after_containing_a_store(%arg0: memref<f32>) -> memref<f32> {336 %0 = arith.constant 0.0 : f32337 %1 = arith.constant 1.0 : f32338 memref.store %0, %arg0[] {tag_name = "pre"} : memref<f32>339 memref.load %arg0[] {tag = "store_with_a_loop_region_after_containing_a_store::before"} : memref<f32>340 test.store_with_a_loop_region %arg0 attributes { tag_name = "region", store_before_region = false } {341 memref.load %arg0[] {tag = "enter_region"} : memref<f32>342 %2 = arith.constant 2.0 : f32343 memref.store %2, %arg0[] {tag_name = "inner"} : memref<f32>344 memref.load %arg0[] {tag = "exit_region"} : memref<f32>345 test.store_with_a_region_terminator346 } : memref<f32>347 memref.load %arg0[] {tag = "after"} : memref<f32>348 memref.store %1, %arg0[] {tag_name = "post"} : memref<f32>349 return {tag = "return"} %arg0 : memref<f32>350}351