Skip to content

[ReachingDefinition] Remove assert to always find underlying value #10530

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -169,10 +169,12 @@ ChangeResult ReachingDefinition::removePotentialModifiers(Value val) {

std::optional<ReachingDefinition::ModifiersTy>
ReachingDefinition::getModifiers(Value val, DataFlowSolver &solver) const {
val = UnderlyingValueAnalysis::getMostUnderlyingValue(val, [&](Value val) {
return solver.lookupState<UnderlyingValueLattice>(val);
});
assert(val && "expected an underlying value");
Value underlyingVal =
UnderlyingValueAnalysis::getMostUnderlyingValue(val, [&](Value val) {
return solver.lookupState<UnderlyingValueLattice>(val);
});
if (underlyingVal)
val = underlyingVal;

if (valueToModifiers.contains(val))
return valueToModifiers.at(val);
Expand All @@ -182,10 +184,12 @@ ReachingDefinition::getModifiers(Value val, DataFlowSolver &solver) const {
std::optional<ReachingDefinition::ModifiersTy>
ReachingDefinition::getPotentialModifiers(Value val,
DataFlowSolver &solver) const {
val = UnderlyingValueAnalysis::getMostUnderlyingValue(val, [&](Value val) {
return solver.lookupState<UnderlyingValueLattice>(val);
});
assert(val && "expected an underlying value");
Value underlyingVal =
UnderlyingValueAnalysis::getMostUnderlyingValue(val, [&](Value val) {
return solver.lookupState<UnderlyingValueLattice>(val);
});
if (underlyingVal)
val = underlyingVal;

if (valueToPotentialModifiers.contains(val))
return valueToPotentialModifiers.at(val);
Expand Down
48 changes: 48 additions & 0 deletions polygeist/test/polygeist-opt/uniformity.mlir
Original file line number Diff line number Diff line change
Expand Up @@ -329,3 +329,51 @@ gpu.func @kernel(%cond: i1, %arg1: memref<?x!sycl_nd_item_2>) kernel {
}

}

// -----

!sycl_array_2 = !sycl.array<[2], (memref<2xi64, 4>)>
!sycl_id_2 = !sycl.id<[2], (!sycl_array_2)>
!sycl_range_2 = !sycl.range<[2], (!sycl_array_2)>
!sycl_accessor_impl_device_2 = !sycl.accessor_impl_device<[2], (!sycl_id_2, !sycl_range_2, !sycl_range_2)>
!sycl_group_2 = !sycl.group<[2], (!sycl_range_2, !sycl_range_2, !sycl_range_2, !sycl_id_2)>
!sycl_item_base_2 = !sycl.item_base<[2, true], (!sycl_range_2, !sycl_id_2, !sycl_id_2)>
!sycl_accessor_2_f32_r_gb = !sycl.accessor<[2, f32, read, global_buffer], (!sycl_accessor_impl_device_2, !llvm.struct<(memref<?xf32, 2>)>)>
!sycl_item_2 = !sycl.item<[2, true], (!sycl_item_base_2)>
!sycl_nd_item_2 = !sycl.nd_item<[2], (!sycl_item_2, !sycl_item_2, !sycl_group_2)>

gpu.module @device_func {

func.func private @test5(%alloca_cond: memref<1xi1>) {
%alloca = memref.alloca() : memref<10xi64>
%c0 = arith.constant 0 : index

// FIXME: Improve uniformity analysis to handle multiple callers,
// with multiple underlying values.
// CHECK: test5_load1, uniformity: unknown
%cond = memref.load %alloca_cond[%c0] { tag = "test5_load1" } : memref<1xi1>

return
}

gpu.func @kernel1(%cond: i1, %arg1: memref<?x!sycl_nd_item_2>) kernel {
%alloca = memref.alloca() : memref<1xi1>
%c0 = arith.constant 0 : index

// COM: Store the condition (uniform) into memory.
memref.store %cond, %alloca[%c0] : memref<1xi1>
func.call @test5(%alloca) : (memref<1xi1>) -> ()
gpu.return
}

gpu.func @kernel2(%cond: i1, %arg1: memref<?x!sycl_nd_item_2>) kernel {
%alloca = memref.alloca() : memref<1xi1>
%c0 = arith.constant 0 : index

// COM: Store the condition (uniform) into memory.
memref.store %cond, %alloca[%c0] : memref<1xi1>
func.call @test5(%alloca) : (memref<1xi1>) -> ()
gpu.return
}

}