Skip to content

Commit 036df28

Browse files
authored
Handle fmuladd (rust-lang#479)
1 parent 79cb030 commit 036df28

File tree

3 files changed

+10
-3
lines changed

3 files changed

+10
-3
lines changed

enzyme/Enzyme/AdjointGenerator.h

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2920,6 +2920,7 @@ class AdjointGenerator
29202920
case Intrinsic::round:
29212921
case Intrinsic::sqrt:
29222922
case Intrinsic::nvvm_sqrt_rn_d:
2923+
case Intrinsic::fmuladd:
29232924
case Intrinsic::fma:
29242925
return;
29252926
default:
@@ -3129,6 +3130,7 @@ class AdjointGenerator
31293130
return;
31303131
}
31313132

3133+
case Intrinsic::fmuladd:
31323134
case Intrinsic::fma: {
31333135
if (vdiff && !gutils->isConstantValue(orig_ops[0])) {
31343136
Value *dif0 = Builder2.CreateFMul(
@@ -3378,7 +3380,8 @@ class AdjointGenerator
33783380
if (Intrinsic::isOverloaded(ID))
33793381
#if LLVM_VERSION_MAJOR >= 13
33803382
llvm::errs() << "cannot handle (reverse) unknown intrinsic\n"
3381-
<< Intrinsic::getName(ID, ArrayRef<Type *>(), nullptr,
3383+
<< Intrinsic::getName(ID, ArrayRef<Type *>(),
3384+
gutils->oldFunc->getParent(),
33823385
nullptr)
33833386
<< "\n"
33843387
<< I;
@@ -3562,6 +3565,7 @@ class AdjointGenerator
35623565
return;
35633566
}
35643567

3568+
case Intrinsic::fmuladd:
35653569
case Intrinsic::fma: {
35663570
if (gutils->isConstantInstruction(&I))
35673571
return;
@@ -3838,7 +3842,8 @@ class AdjointGenerator
38383842
if (Intrinsic::isOverloaded(ID))
38393843
#if LLVM_VERSION_MAJOR >= 13
38403844
llvm::errs() << "cannot handle (forward) unknown intrinsic\n"
3841-
<< Intrinsic::getName(ID, ArrayRef<Type *>(), nullptr,
3845+
<< Intrinsic::getName(ID, ArrayRef<Type *>(),
3846+
gutils->oldFunc->getParent(),
38423847
nullptr)
38433848
<< "\n"
38443849
<< I;

enzyme/Enzyme/DifferentialUseAnalysis.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,8 @@ static inline bool is_use_directly_needed_in_reverse(
104104
II->getIntrinsicID() == Intrinsic::stackrestore) {
105105
return false;
106106
}
107-
if (II->getIntrinsicID() == Intrinsic::fma) {
107+
if (II->getIntrinsicID() == Intrinsic::fma ||
108+
II->getIntrinsicID() == Intrinsic::fmuladd) {
108109
bool needed = false;
109110
if (II->getArgOperand(0) == val &&
110111
!gutils->isConstantValue(II->getArgOperand(1)))

enzyme/Enzyme/TypeAnalysis/TypeAnalysis.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2981,6 +2981,7 @@ void TypeAnalyzer::visitIntrinsicInst(llvm::IntrinsicInst &I) {
29812981
&I);
29822982
return;
29832983

2984+
case Intrinsic::fmuladd:
29842985
case Intrinsic::fma:
29852986
// No direction check as always valid
29862987
updateAnalysis(

0 commit comments

Comments
 (0)