<div dir="ltr">Hello,<div><br></div><div>I was looking into the expression folding strategies of SCEV and found out that we don't fold multiplication and divisions:</div><div><br></div><div><div>define void @test12(i32) {</div><div>entry:</div><div> %1 = udiv i32 %0, 123</div><div> %2 = mul i32 %1, 123</div><div> %3 = udiv i32 %2, 123</div><div> %4 = mul i32 %3, 123</div><div><div> ret void</div><div>}</div></div><div><br></div><div>Will give:</div><div><br></div><div><div> %4 = mul i32 %3, 123</div><div> --> (123 * ((123 * (%0 /u 123)) /u 123)) U: [0,-36) S: [0,-36)</div></div><div><br></div><div>Is there a specific reason for that, or can I add a folding rule?</div><div><br></div><div>Maybe the problem is that division can round off some lsb, and multiplication can wrap around some msb, and therefore we can't easily simplify those. But even adding "exact" on udiv and "nuw nsw" on mul does not help.</div><div><br></div><div>Best regard.</div><div><br></div>-- <br><div class="gmail_signature"><div dir="ltr"><b>Alexandre Isoard</b><br></div></div>
</div></div>