Open gmaxwell opened 4 years ago
Thanks for bug report. The same problem with 32-bit. It is old bug same behaviour with OW1.9. It looks like bug in Code Generator that optimizer doesn't eliminate old code but combine it strange way with optimized one. I will fix it.
I reproduced it on all supported platforms.
below is minimised test sample
Thank you for paying attention to this. :) I'm happy to test out any fixes though I assume you've got it with the reproduction.
It looks like it has similar symptoms as issue #515. It looks like incorrectly deleted code generator internal instructions. In your case following instruction should be deleted from code pipeline, but it is not.
mov si,dx
add si,1
adc cx,0
adc bx,0
adc ax,0
I'm getting incorrect additions of uint64_t as a result of optimization.
Here is a simplified test case:
I did not simplify it as much as possible because I wanted it to be completely clear that this isn't just some confusion about promotion rules. E.g. a version of funbad that does a+2UL is also good. Swapping everything to 32-bit also fixes it.
On a 64-bit Linux host, running 014d6866b392d980c7f70bcd4441c621ae1d1436
The example works fine with -od set.
Disassembly: