From c994307c6353e4535ceb82379ada540b6680c511 Mon Sep 17 00:00:00 2001 From: William Moses Date: Tue, 22 Oct 2024 15:50:59 -0700 Subject: [PATCH] Fix combined temp cache for reverse (#2131) --- enzyme/Enzyme/AdjointGenerator.h | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/enzyme/Enzyme/AdjointGenerator.h b/enzyme/Enzyme/AdjointGenerator.h index bc1eab9283e..4185bf3392f 100644 --- a/enzyme/Enzyme/AdjointGenerator.h +++ b/enzyme/Enzyme/AdjointGenerator.h @@ -5489,8 +5489,11 @@ class AdjointGenerator : public llvm::InstVisitor { It.setHeadBit(true); BuilderZ.SetInsertPoint(It); #endif - cachereplace = BuilderZ.CreatePHI(call.getType(), 1, - call.getName() + "_tmpcacheB"); + if (Mode == DerivativeMode::ReverseModeCombined) + cachereplace = newCall; + else + cachereplace = BuilderZ.CreatePHI(call.getType(), 1, + call.getName() + "_tmpcacheB"); cachereplace = gutils->cacheForReverse( BuilderZ, cachereplace, getIndex(&call, CacheType::Self, BuilderZ));