swift
bec687db - ConstantFolding: remove a wrong peephole optimization for signed "< 0" and ">= 0" comparisons

Commit
4 years ago
ConstantFolding: remove a wrong peephole optimization for signed "< 0" and ">= 0" comparisons The wrong optimization was: fold x < 0 into false, if x is known to be a result of an unsigned operation with overflow checks enabled. It was done under the wrong assumption that the result of an overflow-checked unsigned operation fits into a signed integer and is positive. This is wrong, because the result of an unsigned operation can be larger than Int.max and therefore, when used in a signed integer operation, be re-interpreted as a negative signed value. Fixes a miscompile which resulted in a missing abort on arithmetic overflow. rdar://73596890
Author
Parents
Loading