https://gcc.gnu.org/bugzilla/show_bug.cgi?id=42108

--- Comment #63 from Richard Biener <rguenth at gcc dot gnu.org> ---
Created attachment 34239
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=34239&action=edit
LIM patch

This is a patch to loop invariant motion I was playing with to use range
information to move a stmt up to a place where we can determine the range
information is still correct.  Unfortunately for the testcase this doesn't
allow moving the division at all and we are lucky that we have range
information
at all because of the fortran frontend casting 'n' to unsigned before dividing
by it.

Another possibility is to (finally) teach LIM to hoist code which conditional
execution status needs to be preserved by guarding the hoisted code with that
conditional code.  Thus hoist a / b as either b != 0 ? a / b : 0(?) or
as <execution condition> ? a / b : 0.  Where for this case the condition
of execution is probably more complex than testing the denominator for zero
(thus testing the condition under which we have to preserve execution).
Followup optimizations then eventually can get rid of that condition.

Reply via email to