ICC issue with const and division
Posted: Mon May 01, 2023 1:03 pm
There's a code generation issue involving const values and division, and crops up if you have something like:
where w1 and w2 are words and the const value is > 65535.
Currently the compiler truncates the const value to a word and does a div16x16 operation, so the result will not be correct.
This will be fixed in the next update, but a simple workaround is to cast the operation to a longword...
This won't fix any overflow issues you might have since the operation isn't really valid for all values anyway, but for those values where it is you'll now get the correct result.
Code: Select all
w1 = const / w2
Currently the compiler truncates the const value to a word and does a div16x16 operation, so the result will not be correct.
This will be fixed in the next update, but a simple workaround is to cast the operation to a longword...
Code: Select all
w1 = longword(const/w2)