Skip to content

Commit

Permalink
Fix copyslice v2 (#2211)
Browse files Browse the repository at this point in the history
* Fix copyslice v2

* fix
  • Loading branch information
wsmoses authored Dec 29, 2024
1 parent bdda0ce commit 7cf9e90
Showing 1 changed file with 6 additions and 24 deletions.
30 changes: 6 additions & 24 deletions enzyme/Enzyme/ActivityAnalysis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down Expand Up @@ -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() &&
Expand Down Expand Up @@ -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<AllocaInst>(TmpOrig)) {
newAllocaSet.insert(TmpOrig);
continue;
Expand Down

0 comments on commit 7cf9e90

Please sign in to comment.