Fix linalg.generic access of hoisted constants

Summary: Otherwise the added @generic_const_int will fail

Reviewers: nicolasvasilache, rriddle, mravishankar

Subscribers: mehdi_amini, jpienaar, burmako, shauheen, antiagainst, arpith-jacob, mgester, lucyrfox, liufengdb, Joonsoo, grosul1, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D77109
This commit is contained in:
Ahmed Taei 2020-03-30 17:36:05 -07:00
parent 4eeb56d088
commit 221fa96cd4
2 changed files with 22 additions and 1 deletions

View File

@ -101,7 +101,7 @@ static void inlineRegionAndEmitStdStore(OpType op,
assert(isa<YieldOp>(terminator) && assert(isa<YieldOp>(terminator) &&
"expected an yield op in the end of the region"); "expected an yield op in the end of the region");
for (unsigned i = 0, e = terminator.getNumOperands(); i < e; ++i) { for (unsigned i = 0, e = terminator.getNumOperands(); i < e; ++i) {
std_store(map.lookup(terminator.getOperand(i)), outputBuffers[i], std_store(map.lookupOrDefault(terminator.getOperand(i)), outputBuffers[i],
indexing[i]); indexing[i]);
} }
} }

View File

@ -522,3 +522,24 @@ func @indexed_generic_op_1D_reduce(%arg0: memref<?xf32>,
// CHECK: %[[d:.*]] = select %{{.*}}, %[[b]], %[[c]] // CHECK: %[[d:.*]] = select %{{.*}}, %[[b]], %[[c]]
// CHECK: %[[e:.*]] = addf %[[a]], %[[d]] // CHECK: %[[e:.*]] = addf %[[a]], %[[d]]
// CHECK: store %[[e]], %[[ARG2]][] // CHECK: store %[[e]], %[[ARG2]][]
#trait_const_fill = {
args_in = 0,
args_out = 1,
indexing_maps = [affine_map<(i) -> (i)>],
iterator_types = ["parallel"],
library_call = "some_external_fn"
}
func @generic_const_init(%arg0: memref<?xf32>) {
%cst = constant 1.0 : f32
linalg.generic #trait_const_fill %arg0 {
^bb0(%arg1: f32): // no predecessors
linalg.yield %cst : f32
}: memref<?xf32>
return
}
// CHECK-LABEL: @generic_const_init
// CHECK-SAME: %[[ARG0:.*]]: memref<?xf32>
// CHECK: %[[CONST:.*]] = constant 1.000000e+00 : f32
// CHECK: loop.for %[[i:.*]] = {{.*}}
// CHECK: store %[[CONST]], %[[ARG0]]