------- Additional Comments From rakdver at gcc dot gnu dot org 2005-07-07 10:52 ------- More precisely, the code when it comes to loop optimizer looks basically as
if (len > 3) something; else if (len > 0) something_else; else return; for (i = 0; i < len; i++) whatever; So indeed, len > 0 on each path that reaches the loop, but it is not trivial to deduce. One solution is to use the results of VRP here. However, VRP uses scev analysis, and adding yet another cycle into the current completely incomprehensible nest of dependences between # of iterations analysis and SCEV seems quite scary to me (and there are other technical difficulties with this solution -- running VRP twice is bad from efficiency reasons, but keeping results of VRP valid is not entirely trivial and may prevent some optimizations). The other possibility is to extend the current oracle-like approach (# of iterations analysis basically asks whether a given condition -- len > 0 in this case -- is true, and answer is computed on-demand by traversing SSA and dominance tree) to handle also this case. This would however need to have the ASSERT_EXPRs (so we either would need to insert them before loop optimizer, or keep them valid since VRP, neither of which seems to be good for performance and memory consumption). -- What |Removed |Added ---------------------------------------------------------------------------- CC| |dnovillo at redhat dot com http://gcc.gnu.org/bugzilla/show_bug.cgi?id=22184