#include "loop-unroll.h"
#include "regs.h"
#include "df.h"
+#include "targhooks.h"
/* This module is used to modify loops with a determinable number of
iterations to use special low-overhead looping instructions.
basic_block loop_end = desc->out_edge->src;
bool fail = bitmap_intersect_p (df_get_live_out (loop_end), modified);
+ /* iv_analysis_loop_init calls df_analyze_loop, which computes just
+ partial df for blocks of the loop only. The above will catch if
+ any of the modified registers are use inside of the loop body, but
+ it will most likely not have accurate info on registers used
+ at the destination of the out_edge. We call df_analyze on the
+ whole function at the start of the pass though and iterate only
+ on innermost loops or from innermost loops, so
+ live in on desc->out_edge->dest should be still unmodified from
+ the initial df_analyze. */
+ if (!fail)
+ fail = bitmap_intersect_p (df_get_live_in (desc->out_edge->dest),
+ modified);
BITMAP_FREE (modified);
if (fail)
df_live_set_all_dirty ();
}
- for (auto loop : loops_list (cfun, 0))
+ df_analyze ();
+
+ for (auto loop : loops_list (cfun,
+ targetm.can_use_doloop_p
+ == can_use_doloop_if_innermost
+ ? LI_ONLY_INNERMOST : LI_FROM_INNERMOST))
doloop_optimize (loop);
if (optimize == 1)
--- /dev/null
+// PR rtl-optimization/113994
+// { dg-do run }
+
+#include <string>
+
+void
+foo (const std::string &x, size_t &y, std::string &z)
+{
+ size_t w = x.find (']');
+ if (w >= x.size ())
+ return;
+ else if (w == 1)
+ y = std::string::npos;
+ while (++w < x.size () && x[w] == u'.')
+ ;
+ z = x.substr (w);
+}
+
+__attribute__((noipa)) void
+bar ()
+{
+}
+
+int
+main ()
+{
+ size_t y = 0;
+ std::string z;
+ foo ("[0]", y, z);
+ bar ();
+}
--- /dev/null
+/* PR rtl-optimization/116799 */
+
+const char *l;
+
+__attribute__((noipa)) void
+foo (const char *x, const char *y, int z)
+{
+ if (x != l + 1 || y != x || z)
+ __builtin_abort ();
+}
+
+__attribute__((noipa)) void
+bar (const char *x, char *v)
+{
+ const char *w = x + __builtin_strlen (x);
+
+ while (x[0] == '*' && x < w - 1)
+ x++;
+
+ const char *y = w - 1;
+ int z = 1;
+ if (y >= x)
+ {
+ while (y - x > 0 && *y == '*')
+ y--;
+ z = 0;
+ }
+ int i = 0;
+ if (z)
+ v[i++] = 'a';
+ v[i] = 'b';
+ foo (x, y, z);
+}
+
+int
+main ()
+{
+ char v[2] = { 0 };
+ l = "**";
+ bar (l, v);
+}