From e22658c231189a6595e12e8f349943d60551cfcc Mon Sep 17 00:00:00 2001 From: Joe Wallwork Date: Mon, 11 May 2026 11:55:32 +0100 Subject: [PATCH 1/3] Skip differentiation of integers --- enzyme/Enzyme/AdjointGenerator.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/enzyme/Enzyme/AdjointGenerator.h b/enzyme/Enzyme/AdjointGenerator.h index 86341a9fadae..d61c19369e45 100644 --- a/enzyme/Enzyme/AdjointGenerator.h +++ b/enzyme/Enzyme/AdjointGenerator.h @@ -2611,7 +2611,7 @@ class AdjointGenerator : public llvm::InstVisitor { case Instruction::Mul: case Instruction::Sub: case Instruction::Add: { - if (looseTypeAnalysis) { + if (looseTypeAnalysis || BO.getType()->isIntOrIntVectorTy()) { llvm::errs() << "warning: binary operator is integer and assumed constant: " << BO << "\n"; From 19f04f76a88692eb0902f50357f6101e8d374849 Mon Sep 17 00:00:00 2001 From: Joe Wallwork Date: Mon, 11 May 2026 11:55:47 +0100 Subject: [PATCH 2/3] More helpful error message for binary ops --- enzyme/Enzyme/AdjointGenerator.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/enzyme/Enzyme/AdjointGenerator.h b/enzyme/Enzyme/AdjointGenerator.h index d61c19369e45..de35176ffb9f 100644 --- a/enzyme/Enzyme/AdjointGenerator.h +++ b/enzyme/Enzyme/AdjointGenerator.h @@ -2639,7 +2639,7 @@ class AdjointGenerator : public llvm::InstVisitor { << " val:" << gutils->isConstantValue(&I) << " type: " << TR.query(&I).str() << "\n"; } - ss << "cannot handle unknown binary operator: " << BO << "\n"; + ss << "derivative of active binary operator not known: " << BO << "\n"; EmitNoDerivativeError(ss.str(), BO, gutils, Builder2); } From 644ef32e2440b1255ad628c405bc03b7214fd805 Mon Sep 17 00:00:00 2001 From: Joe Wallwork Date: Mon, 11 May 2026 14:17:54 +0100 Subject: [PATCH 3/3] Equivalent fix for forward mode --- enzyme/Enzyme/AdjointGenerator.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/enzyme/Enzyme/AdjointGenerator.h b/enzyme/Enzyme/AdjointGenerator.h index de35176ffb9f..18d2f0dc4d9f 100644 --- a/enzyme/Enzyme/AdjointGenerator.h +++ b/enzyme/Enzyme/AdjointGenerator.h @@ -2881,7 +2881,7 @@ class AdjointGenerator : public llvm::InstVisitor { case Instruction::Mul: case Instruction::Sub: case Instruction::Add: { - if (looseTypeAnalysis) { + if (looseTypeAnalysis || BO.getType()->isIntOrIntVectorTy()) { forwardModeInvertedPointerFallback(BO); llvm::errs() << "warning: binary operator is integer and constant: " << BO << "\n"; @@ -2909,7 +2909,7 @@ class AdjointGenerator : public llvm::InstVisitor { << " val:" << gutils->isConstantValue(&I) << " type: " << TR.query(&I).str() << "\n"; } - ss << "cannot handle unknown binary operator: " << BO << "\n"; + ss << "derivative of active binary operator not known: " << BO << "\n"; auto rval = EmitNoDerivativeError(ss.str(), BO, gutils, Builder2); if (!rval) rval = Constant::getNullValue(gutils->getShadowType(BO.getType()));