Skip to content

Initialize inactive reverse tape values#2852

Open
minansys wants to merge 2 commits into
EnzymeAD:mainfrom
minansys:fix/inactive-tape-lcssa
Open

Initialize inactive reverse tape values#2852
minansys wants to merge 2 commits into
EnzymeAD:mainfrom
minansys:fix/inactive-tape-lcssa

Conversation

@minansys
Copy link
Copy Markdown
Collaborator

@minansys minansys commented Jun 5, 2026

Fixes #2834 and #2629.\n\nRoot cause:\n- #2834: augmented reverse tapes were assembled by sparse stores into the returned tape aggregate. When a guarding branch was not taken, SROA exposed the unstored fields as undef-fed PHIs, then those values were packed into the tape. The tape backing slot now gets a defined zero/null baseline before path-local tape stores.\n- #2629: manual LCSSA values synthesized for blocks where the primal instruction is inactive used undef. Enzyme postopt could propagate that through noundef math and infer an invalid guard assumption. Those inactive LCSSA entries now use the type's safe zero/null value.\n\nTests:\n- llvm-lit -v /home/minxu/code/enzyme/build/enzyme2-llvmorg-19.1.7/test/Enzyme/ReverseMode/inactive-tape-values.ll\n- llvm-lit -v /home/minxu/code/enzyme/build/enzyme2-llvmorg-19.1.7/test/Integration/ReverseMode/nested_guard_inactive_lcssa.c\n- manual #2834 opt pipeline with LLVM 19.1.7: no remaining i1/ptr/double PHIs with undef in the generated output\n- manual #2629 direct Clang plugin repros at -O0/-O1 for minimized C and original C++ repro: gradients are {1} and {1,1,1}\n

@minansys minansys force-pushed the fix/inactive-tape-lcssa branch from a116f6a to 63a1af7 Compare June 5, 2026 11:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Enzyme generates undef-fed tape PHIs for packed-state nested guard reproducer

2 participants