Mark AllocOp as being free of side effects

PiperOrigin-RevId: 221863955
This commit is contained in:
Uday Bondhugula 2018-11-16 15:34:10 -08:00 committed by jpienaar
parent 8c903a3c9d
commit 6b52ac3aa6
2 changed files with 6 additions and 8 deletions

View File

@ -100,8 +100,8 @@ private:
///
/// This operation returns a single ssa value of memref type, which can be used
/// by subsequent load and store operations.
class AllocOp
: public Op<AllocOp, OpTrait::VariadicOperands, OpTrait::OneResult> {
class AllocOp : public Op<AllocOp, OpTrait::VariadicOperands,
OpTrait::OneResult, OpTrait::HasNoSideEffect> {
public:
/// The result of an alloc is always a MemRefType.
MemRefType getType() const {

View File

@ -46,6 +46,7 @@ mlfunc @test_commutative(%arg0: i32) -> (i32, i32) {
// CHECK-LABEL: mlfunc @trivial_dce
mlfunc @trivial_dce(%arg0: tensor<8x4xf32>) {
%0 = dim %arg0, 1 : tensor<8x4xf32>
%1 = alloc() : memref<1024xf32>
// CHECK-NEXT: return
return
}
@ -145,21 +146,18 @@ mlfunc @dyn_shape_fold(%L : index, %M : index) -> memref<? x ? x f32> {
// CHECK-NEXT: %1 = alloc(%arg1) : memref<4x1024x8x512x?xf32>
%b = alloc(%N, %K, %M) : memref<4 x ? x 8 x ? x ? x f32>
// CHECK-NEXT: %2 = alloc() : memref<512x1024xi32>
%c = alloc(%K, %N) : memref<? x ? x i32>
// CHECK: for %i0 =
for %i = 0 to %L {
// CHECK-NEXT: for %i1 =
for %j = 0 to 10 {
// CHECK-NEXT: %3 = load %0[%i0, %i1] : memref<?x1024xf32>
// CHECK-NEXT: store %3, %1[%c0, %c0, %i0, %i1, %c0] : memref<4x1024x8x512x?xf32>
// CHECK-NEXT: %2 = load %0[%i0, %i1] : memref<?x1024xf32>
// CHECK-NEXT: store %2, %1[%c0, %c0, %i0, %i1, %c0] : memref<4x1024x8x512x?xf32>
%v = load %a[%i, %j] : memref<?x?xf32>
store %v, %b[%zero, %zero, %i, %j, %zero] : memref<4x?x8x?x?xf32>
}
}
// CHECK: %4 = alloc() : memref<9x9xf32>
// CHECK: %3 = alloc() : memref<9x9xf32>
%d = alloc(%nine, %nine) : memref<? x ? x f32>
return %d : memref<? x ? x f32>