[BugFix] Missing Recursive Loop Var Checking in Loop Unswitching#1801
[BugFix] Missing Recursive Loop Var Checking in Loop Unswitching#1801LeiWang1999 merged 2 commits intotile-ai:mainfrom
Conversation
…nd add corresponding test case
|
👋 Hi! Thank you for contributing to the TileLang project. Please remember to run We appreciate you taking this step! Our team will review your contribution, and we look forward to your awesome work! 🚀 |
📝 WalkthroughWalkthroughReplaced a direct Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@src/transform/loop_unswitching.cc`:
- Line 357: Replace the noisy production LOG call that prints loop-invariant IR
with a debug-only log and fix its spacing: change the LOG(INFO) << "Loop
Invariant" << ffi::GetRef<IfThenElse>(op); occurrence in loop_unswitching.cc to
use DLOG(INFO) or VLOG(1) (depending on desired verbosity) and ensure the
message includes a space or separator (e.g., "Loop Invariant: ") before the
ffi::GetRef<IfThenElse>(op) output so it only emits in debug/verbose builds and
is properly formatted.
🧹 Nitpick comments (1)
testing/python/transform/test_tilelang_transform_loop_unswitching.py (1)
389-400: Test only checks that compilation doesn't crash — consider adding a structural assertion.All other tests in this file use
_check(before, expected)to verify the transformed IR structurally. This test only calls.compile(), so it validates that the bug no longer causes a crash or invalid IR, but doesn't assert that the condition is actually not hoisted.If it's difficult to express the expected output via
@T.prim_funcfor this kernel style, a comment explaining why this test is compile-only and what invariant it guards would be helpful for future maintainers.Based on learnings: "For Python tests of the tilelang transform passes, focus assertions on structural patterns in the generated kernel source (e.g., hoisting behavior) rather than specific numeric literals."
UsesLoopVarThroughLetBindingsdoes not check the variable recursively in the let binding stack. This pr fixes it.Summary by CodeRabbit
Bug Fixes
Tests