[Compiler] Currency: do not fold x mod 1 / x mod -1 before scaling

x mod 1 and x mod -1 are folded to 0 by the integer identities in tmoddivnode.simplify, which pass_typecheck calls before the Currency operands share their scale. For a Currency A and an integer literal divisor that drops the fractional remainder: 10.0006 mod 1 gives 0.0000 instead of 0.0006. With Currency(1) or a variable divisor the result is already correct.

This suppresses only these two folds when an operand is Currency and the node is not internal, so the remainder is computed on the scaled values. The division-by-zero and ISO-mode diagnostics in the same function are unchanged. tw41865j (already in main) covers the fix; the new fail tests tw41865k and tw41865l check that A mod 0 still reports "Division by zero" and that ISO mode still rejects a negative divisor for Currency.

Measured on native aarch64-win64, two complete trees from main c94c8753ec, differing only in this commit, each installed and used with its own units:

main c94c8753ec this MR
A mod 1, A mod -1 (A = 10.0006, raw) 0 6
tw41865j at its options, -O-, -O2, -O4, -O4 -Oofastmath exit 1 exit 0
tw41865k, tw41865l pass pass
tw41865a-i unchanged unchanged

Full make allexectests CPU_TARGET=aarch64 OS_TARGET=win64 in both trees, one after the other: 3914 programs run in each, 54 failing on main and 53 with this commit; the only difference is tw41865j.

Edited by Sven Harazim

Merge request reports

Loading
Loading