Multiplication by −1 does not fold with surrounding multipliers (incl. other −1s).
Derived from [this topic](https://forum.lazarus.freepascal.org/index.php/topic,64736.0.html). Slightly reminds me of my [old report](https://gitlab.com/freepascal.org/fpc/source/-/issues/39997), but might be a separate issue. This code: ```pascal var x: integer; begin x := 2 + random(0); x := x * -3 * 4 * -5 * -1 * -1 * -1 * -5 * 6 * -7; // (A) x := -3 * 4 * -5 * -1 * -1 * -1 * -5 * 6 * -7 * x; // (B) writeln(x); end. ``` Compiles as follows: ```nasm ; x := x * -3 * 4 * -5 * -1 * -1 * -1 * -5 * 6 * -7; imul ebx,eax,$3C neg ebx neg ebx neg ebx imul ebx,ebx,$000000D2 ; x := -3 * 4 * -5 * -1 * -1 * -1 * -5 * 6 * -7 * x; imul ebx,ebx,$FFFFCEC8 ``` Each `-1` became a separate `neg`. Since multiplication is commutative, there is no reason for these expressions to fold differently.
issue