for this case, ((a + ia) / ib + ic) -> (a + (ia + ib*ic)) / ib
when ic is negative, ic=-1, ib=2 and a + ia = 1
before optimization,
1/ 2 - 1 = -1
after optimization
(1 - 1 × 2) / 2 = 0
comes out different result, if hardware round up differently for 1/2 and -1/2
Sure, we can send a PR to disable this optimization. The main problem is that Halide used a different semantics of div and mod(which rounds down) for negative integers as well.