This IR causes an SSA violation in the EmplaceAllocations pass in Stream

util.global private @_constant : !stream.resource<constant>
util.global private @_constant_0 : !stream.resource<constant>
func.func private @_rng_normal_2d() {
  %c0_i8 = arith.constant 0 : i8
  %c8 = arith.constant 8 : index
  %c60 = arith.constant 60 : index
  %c0 = arith.constant 0 : index
  %c64 = arith.constant 64 : index
  %c32 = arith.constant 32 : index
  %c1065353216_i32 = arith.constant 1065353216 : i32
  %c4 = arith.constant 4 : index
  %_constant = util.global.load @_constant : !stream.resource<constant>
  %_constant_0 = util.global.load @_constant_0 : !stream.resource<constant>
  %0 = stream.async.transfer %_constant : !stream.resource<constant>{%c60} -> !stream.resource<*>{%c60}
  %1 = stream.async.transfer %_constant_0 : !stream.resource<constant>{%c8} -> !stream.resource<*>{%c8}
  %2 = stream.async.splat %c0_i8 : i8 -> !stream.resource<*>{%c4}
  %3 = util.optimization_barrier %2 : !stream.resource<*>
  %4 = stream.async.splat %c1065353216_i32 : i32 -> !stream.resource<*>{%c4}
  %5 = util.optimization_barrier %4 : !stream.resource<*>
  %6 = util.optimization_barrier %1 : !stream.resource<*>
  %7 = stream.resource.size %5 : !stream.resource<*>
  %8 = stream.resource.size %3 : !stream.resource<*>
  %9:2 = stream.async.dispatch @_rng_normal_2d_dispatch_0::@_rng_normal_2d_dispatch_0_generic_8[%c8](%5[%c0 to %7 for %7], %3[%c0 to %8 for %8]) : (!stream.resource<*>{%7}, !stream.resource<*>{%8}) -> (!stream.resource<*>{%c32}, !stream.resource<*>{%c32})
  %10 = stream.async.alloca : !stream.resource<*>{%c64}
  %11 = stream.async.update %9#0, %10[%c0 to %c32] : !stream.resource<*>{%c32} -> %10 as !stream.resource<*>{%c64}
  %12 = stream.async.update %9#1, %11[%c32 to %c64] : !stream.resource<*>{%c32} -> %11 as !stream.resource<*>{%c64}
  %13 = stream.async.slice %12[%c0 to %c60] : !stream.resource<*>{%c64} -> !stream.resource<*>{%c60}
  %14 = stream.async.transfer %13 : !stream.resource<*>{%c60} -> !stream.resource<external>{%c60}
  %15 = stream.tensor.export %14 : tensor<3x5xf32> in !stream.resource<external>{%c60} -> tensor<3x5xf32>
  %16 = stream.async.transfer %0 : !stream.resource<*>{%c60} -> !stream.resource<external>{%c60}
  %17 = stream.tensor.export %16 : tensor<3x5xf32> in !stream.resource<external>{%c60} -> tensor<3x5xf32>
  check.expect_almost_eq(%15, %17) : tensor<3x5xf32>
  return
}
$ iree-opt  --iree-stream-emplace-allocations emplace_allocations_repro.mlir 
emplace_allocations_repro.mlir:23:10: error: operand #4 does not dominate this use
  %9:2 = stream.async.dispatch @_rng_normal_2d_dispatch_0::@_rng_normal_2d_dispatch_0_generic_8[%c8](%5[%c0 to %7 for %7], %3[%c0 to %8 for %8]) : (!stream.resource<*>{%7}, !stream.resource<*>{%8}) -> (!stream.resource<*>{%c32}, !stream.resource<*>{%c32})
         ^
emplace_allocations_repro.mlir:23:10: note: see current operation: %20:2 = "stream.async.dispatch"(%1, %15, %13, %19, %20#0, %17, %18, %4, %4, %3, %3, %3, %5, %17, %18, %5, %4, %17, %18, %5, %5, %4, %4) {entry_point = @_rng_normal_2d_dispatch_0::@_rng_normal_2d_dispatch_0_generic_8, operand_segment_sizes \
= array<i32: 1, 4, 4, 4, 4, 4, 2>, tied_operands = [2 : index, 3 : index]} : (index, !stream.resource<*>, !stream.resource<*>, !stream.resource<*>, !stream.resource<*>, index, index, index, index, index, index, index, index, index, index, index, index, index, index, index, index, index, index) -> (!stream\
.resource<*>, !stream.resource<*>)
emplace_allocations_repro.mlir:23:10: note: operand defined here (op in the same block)
0

Encountered with #11980

0

I havent traiged it, but @benvanik FYI...

0

weiiird #20:2 = "stream.async.dispatch"(%1, %15, %13, %19, %20#0 image

0

(I can take a look at this in the morning - thanks for the reproducer!)

0
© 2022 pullanswer.com - All rights reserved.