On the same Windows 11 machine with the same C compiler (Visual Studio 2022):
$Version
(* "13.3.1 for Microsoft Windows (64-bit) (July 24, 2023)" *)
c = Compile[{{x, _Real}, {n, _Integer}},
Module[{sum, inc}, sum = 1.0; inc = 1.0;
Do[inc = inc*x/i; sum = sum + inc, {i, n}]; sum],
CompilationTarget -> "C"];
c[1.5, 10^9] // AbsoluteTiming
(* {0.691227, 4.48169} *)
cNormal = Compile[{{x, _Real}, {n, _Integer}},
Module[{sum, inc}, sum = 1.0; inc = 1.0;
Do[inc = inc*x/i; sum = sum + inc, {i, n}]; sum]];
cNormal[1.5, 10^9] // AbsoluteTiming
(* {14.8374, 4.48169} *)
But with the new version 14.1:
$Version
(* "14.1.0 for Microsoft Windows (64-bit) (July 16, 2024)" *)
c = Compile[{{x, _Real}, {n, _Integer}},
Module[{sum, inc}, sum = 1.0; inc = 1.0;
Do[inc = inc*x/i; sum = sum + inc, {i, n}]; sum],
CompilationTarget -> "C"];
c[1.5, 10^9] // AbsoluteTiming
(* {56.2374, 4.48169} *)
cNormal = Compile[{{x, _Real}, {n, _Integer}},
Module[{sum, inc}, sum = 1.0; inc = 1.0;
Do[inc = inc*x/i; sum = sum + inc, {i, n}]; sum]];
cNormal[1.5, 10^9] // AbsoluteTiming
(* {25.5739, 4.48169} *)
Did anyone else notice similar behavior with the 14.1 compiler in their installation?
RuntimeOptions -> {"CatchMachineOverflow" -> True}
$\endgroup$RuntimeOptions -> {"CatchMachineOverflow" -> False}
seems to be a workaround. I am not sure if this should be reported to Wolfram as a bug or inadequate documentation? $\endgroup$