From 7cf9e90de211ed525aca58e0930b14a827e20bba Mon Sep 17 00:00:00 2001 From: William Moses Date: Sat, 28 Dec 2024 22:38:20 -0500 Subject: [PATCH] Fix copyslice v2 (#2211) * Fix copyslice v2 * fix --- enzyme/Enzyme/ActivityAnalysis.cpp | 30 ++++++------------------------ 1 file changed, 6 insertions(+), 24 deletions(-) diff --git a/enzyme/Enzyme/ActivityAnalysis.cpp b/enzyme/Enzyme/ActivityAnalysis.cpp index 67972fdcc8c..44e88abe351 100644 --- a/enzyme/Enzyme/ActivityAnalysis.cpp +++ b/enzyme/Enzyme/ActivityAnalysis.cpp @@ -668,7 +668,7 @@ static inline void propagateArgumentInformation( // Only the 0-th arg impacts activity if (Name == "jl_genericmemory_copy_slice" || Name == "ijl_genericmemory_copy_slice") { - propagateFromOperand(CI.getArgOperand(1)); + propagateFromOperand(CI.getArgOperand(0)); return; } @@ -1613,29 +1613,6 @@ bool ActivityAnalyzer::isConstantValue(TypeResults const &TR, Value *Val) { return true; } - if (funcName == "jl_genericmemory_copy_slice" || - funcName == "ijl_genericmemory_copy_slice") { - if (directions == UP) { - if (isConstantValue(TR, op->getArgOperand(0))) { - InsertConstantValue(TR, Val); - return true; - } - } else { - if (UpHypothesis->isConstantValue(TR, op->getArgOperand(0))) { - InsertConstantValue(TR, Val); - insertConstantsFrom(TR, *UpHypothesis); - return true; - } - } - if (EnzymeEnableRecursiveHypotheses) { - ReEvaluateValueIfInactiveValue[op->getArgOperand(0)].insert(Val); - if (TmpOrig != Val) { - ReEvaluateValueIfInactiveValue[op->getArgOperand(0)].insert( - TmpOrig); - } - } - } - // If requesting empty unknown functions to be considered inactive, // abide by those rules if (called && EnzymeEmptyFnInactive && called->empty() && @@ -2751,6 +2728,11 @@ bool ActivityAnalyzer::isValueInactiveFromUsers(TypeResults const &TR, if (AllocaSet.count(TmpOrig)) { continue; } + // We are literally storing our value into ourselves [or relevant + // derived pointer] + if (TmpOrig == val) { + continue; + } if (isa(TmpOrig)) { newAllocaSet.insert(TmpOrig); continue;