diff --git a/enzyme/Enzyme/CApi.cpp b/enzyme/Enzyme/CApi.cpp index dc58942da147..929729cb6c90 100644 --- a/enzyme/Enzyme/CApi.cpp +++ b/enzyme/Enzyme/CApi.cpp @@ -1263,13 +1263,15 @@ LLVMValueRef EnzymeComputeByteOffsetOfGEP(LLVMBuilderRef B_r, LLVMValueRef V_r, IRBuilder<> &B = *unwrap(B_r); auto T = cast(unwrap(T_r)); auto width = T->getBitWidth(); - auto gep = cast(unwrap(V_r)); + auto uw = unwrap(V_r); + GEPOperator *gep = isa(uw) + ? cast(cast(uw)) + : cast(cast(uw)); auto &DL = B.GetInsertBlock()->getParent()->getParent()->getDataLayout(); MapVector VariableOffsets; APInt Offset(width, 0); - bool success = - collectOffset(cast(gep), DL, width, VariableOffsets, Offset); + bool success = collectOffset(gep, DL, width, VariableOffsets, Offset); (void)success; assert(success); Value *start = ConstantInt::get(T, Offset);