Skip to content

Commit

Permalink
debugging mem2reg
Browse files Browse the repository at this point in the history
  • Loading branch information
Mike-Leo-Smith committed Feb 10, 2025
1 parent bd32ded commit 71a9998
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 16 deletions.
2 changes: 1 addition & 1 deletion src/xir/passes/dom_tree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
namespace luisa::compute::xir {

inline DomTreeNode::DomTreeNode(BasicBlock *block) noexcept
: _parent{nullptr}, _block{block} {}
: _block{block}, _parent{nullptr} {}

inline void DomTreeNode::add_child(DomTreeNode *child) noexcept {
LUISA_DEBUG_ASSERT(child != nullptr && child->_parent == nullptr && child != this, "Invalid child.");
Expand Down
28 changes: 13 additions & 15 deletions src/xir/tests/test_mem2reg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,20 @@ int main(int argc, char *argv[]) {

using namespace luisa::compute;
auto shader = device.compile<1>([&](UInt n) noexcept {
auto x = def<uint>();
auto zero = def(0u);
auto one = def(1u);
$while (true) {
$if (n == 0u) {
x = zero;
}
$else {
n -= 1u;
x = one;
};
$if (n == 0u) {
$break;
};
auto b = compute::detail::FunctionBuilder::current();
auto t = Type::of<uint>();
auto x = b->local(t);
auto zero = b->literal(t, 0u);
auto one = b->literal(t, 1u);
$if (n == 0u) {
}
$elif (n == 1u) {
// b->assign(x, one);
}
$else {
b->assign(x, zero);
};
buffer->write(0u, x);
buffer->write(0u, def<uint>(x));
});

uint result = 0u;
Expand Down

0 comments on commit 71a9998

Please sign in to comment.