There is a way to optimize this program?

Wired, i tried build above examples again on my laptop

 ╰─ $ ./collatz3
Seed 1000000000 Steps: 100
collatz took: 00:02:05.057338846

--mcpu native
 ╰─ $ ./collatz3
Seed 1000000000 Steps: 100
collatz took: 00:02:06.073337643
 ╰─ $ ./collatz1
Seed 1000000000 Steps: 100
collatz took: 00:02:45.230708896

--mcpu native
 ╰─ $ ./collatz1
Seed 1000000000 Steps: 100
collatz took: 00:02:49.934104333
+ cr build --release 1.cr -o 1
+ ./1
collatz took: 00:02:23.130819476
+ echo -----------------
+ cr build --release --mcpu native 1.cr -o 2
+ ./2
collatz took: 00:03:07.363442950

All my benchmark, --mcpu native version is slower than another, the results completely opposite to before!

I don’t know what happened, this really wired.

some factors concerned:

  1. When i last ran this benchmarks, my laptop is plugged by a Dell monitor, TypeC, 90W, but, i connect a 120W AC adapter this time, although latter has much better performance, but, i consider run both with same condition is should comparable.

2. When i last ran, I use Crystal compiler which built without --mcpu native, but my current compiler built with this option.

  1. when i last ran, compiler built with llvm 17, but, llvm 18 this time.

EDIT: I tried recompile my crystal compiler without --mcpu native as before, and run benchmark again, as you can see, almost no difference, so above factor 2 can be ignored.

 ╰─ $ sh 1.sh
+ cr build --release 1.cr -o 1
+ ./1
collatz took: 00:02:22.366686933
+ echo -----------------
+ cr build --release --mcpu native 1.cr -o 2
+ ./2
collatz took: 00:03:07.554092518

And i don’t think the factor 1 is the reason, so, the only valid factor is, llvm update from 17 to 18?