Skip to content

Commit 34fb64a

Browse files
authored
[Backend] Fix alias analysis with ub.poison (#7463)
Optimistically assume poison values alias nothing.
1 parent cdd7a3d commit 34fb64a

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

lib/Analysis/Alias.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#include "triton/Analysis/Alias.h"
22

3+
#include "mlir/Dialect/UB/IR/UBOps.h"
34
#include "mlir/Support/LLVM.h"
45
#include "triton/Dialect/TritonGPU/IR/Dialect.h"
56

@@ -38,6 +39,9 @@ LogicalResult SharedMemoryAliasAnalysis::visitOperation(
3839
} else if (op->hasTrait<OpTrait::MemDescViewTrait>()) {
3940
aliasInfo = AliasInfo(operands[0]->getValue());
4041
pessimistic = false;
42+
} else if (isa<ub::PoisonOp>(op)) {
43+
aliasInfo = AliasInfo();
44+
pessimistic = false;
4145
} else {
4246
assert(!isa<triton::gpu::MemDescType>(result.getType()) &&
4347
"unknown operation creating memory descriptor");

test/Analysis/test-alias.mlir

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,4 +191,18 @@ tt.func @cf_for(%arg0: index, %arg1: index, %arg2: index, %arg3: !tt.ptr<f16>, %
191191
tt.return
192192
}
193193

194+
tt.func @poison_memdesc(%arg0: i1) {
195+
// expected-remark @below {{%0 -> %0}}
196+
%0 = ttg.local_alloc : () -> !ttg.memdesc<128x32xf16, #A_SHARED, #ttg.shared_memory, mutable>
197+
cf.cond_br %arg0, ^bb1, ^bb2(%0 : !ttg.memdesc<128x32xf16, #A_SHARED, #ttg.shared_memory, mutable>)
198+
^bb1:
199+
%1 = ub.poison : !ttg.memdesc<128x32xf16, #A_SHARED, #ttg.shared_memory, mutable>
200+
cf.br ^bb2(%1 : !ttg.memdesc<128x32xf16, #A_SHARED, #ttg.shared_memory, mutable>)
201+
^bb2(%2: !ttg.memdesc<128x32xf16, #A_SHARED, #ttg.shared_memory, mutable>):
202+
%c0_i32 = arith.constant 0 : i32
203+
// expected-remark @below {{%3 -> %0}}
204+
%3 = ttg.memdesc_subview %2[%c0_i32, %c0_i32] : !ttg.memdesc<128x32xf16, #A_SHARED, #ttg.shared_memory, mutable> -> !ttg.memdesc<128x32xf16, #A_SHARED, #ttg.shared_memory, mutable>
205+
tt.return
206+
}
207+
194208
} // module

0 commit comments

Comments
 (0)