[inductor] Fix loop-local load CSE lifetime (#194786)
Human context: fix for https://github.com/pytorch/pytorch/issues/194490) exposed by https://github.com/pytorch/pytorch/pull/184287 although the underlying cause was prior CSE / loop hoisting logic (and ultimately the fact that this is all tied to one very complicated file).. Triton load placement and CSE lifetime used separate heuristics. An indirect load emitted inside a loop could consequently remain cached after loop closure and be reused by an epilogue even though its temporary did not dominate that use. Use the selected load buffer as the source of truth for whether a CSE value survives loop closure. Also prevent loads carrying reduction masks from being hoisted before those masks are defined. Test Plan: ``` python test/inductor/test_indexing.py ReductionInvariantIndexingTests python test/inductor/test_codegen_triton.py -k reduction_invariant_load_indexing git diff --check lintrunner -a test/inductor/test_indexing.py torch/_inductor/codegen/triton.py ``` The two test commands and git diff check pass. Lintrunner was invoked, but Pyrefly failed on unrelated repository-wide missing-attribute errors because this detached worktree has no initialized lintrunner data. AI-Assisted: Author reviewed and validated all AI-generated content. Pull Request resolved: https://github.com/pytorch/pytorch/pull/194786 Approved by: https://github.com/atalman, https://github.com/karthickai
E
eellison committed
60598ed3c8773875c0923101d54f206303b2f59f
Parent: 5f965f4
Committed by PyTorch MergeBot <pytorchmergebot@users.noreply.github.com>
on 8/26/2026, 12:05:06 AM