@@ -1413,6 +1413,7 @@ static bool interp__builtin_ia32_pext(InterpState &S, CodePtr OpPC,
14131413 return true ;
14141414}
14151415
1416+ // / (CarryIn, LHS, RHS, Result)
14161417static bool interp__builtin_ia32_addcarry_subborrow (InterpState &S,
14171418 CodePtr OpPC,
14181419 const InterpFrame *Frame,
@@ -1423,16 +1424,17 @@ static bool interp__builtin_ia32_addcarry_subborrow(InterpState &S,
14231424 !Call->getArg (2 )->getType ()->isIntegerType ())
14241425 return false ;
14251426
1426- APSInt CarryIn = peekToAPSInt (
1427- S.Stk , *S.getContext ().classify (Call->getArg (0 )),
1428- align (primSize (*S.getContext ().classify (Call->getArg (2 )))) +
1429- align (primSize (*S.getContext ().classify (Call->getArg (1 )))) +
1430- align (primSize (*S.getContext ().classify (Call->getArg (0 )))));
1427+ PrimType CarryInT = *S.getContext ().classify (Call->getArg (0 ));
1428+ PrimType LHST = *S.getContext ().classify (Call->getArg (1 ));
1429+ PrimType RHST = *S.getContext ().classify (Call->getArg (2 ));
1430+ unsigned PtrSize = align (primSize (PT_Ptr));
1431+ APSInt CarryIn =
1432+ peekToAPSInt (S.Stk , CarryInT,
1433+ PtrSize + align (primSize (RHST)) + align (primSize (LHST)) +
1434+ align (primSize (CarryInT)));
14311435 APSInt LHS = peekToAPSInt (
1432- S.Stk , *S.getContext ().classify (Call->getArg (1 )),
1433- align (primSize (*S.getContext ().classify (Call->getArg (2 )))) +
1434- align (primSize (*S.getContext ().classify (Call->getArg (1 )))));
1435- APSInt RHS = peekToAPSInt (S.Stk , *S.getContext ().classify (Call->getArg (2 )));
1436+ S.Stk , LHST, PtrSize + align (primSize (RHST)) + align (primSize (LHST)));
1437+ APSInt RHS = peekToAPSInt (S.Stk , RHST, PtrSize + align (primSize (RHST)));
14361438
14371439 bool IsAdd = BuiltinOp == clang::X86::BI__builtin_ia32_addcarryx_u32 ||
14381440 BuiltinOp == clang::X86::BI__builtin_ia32_addcarryx_u64;
0 commit comments