> From: gcc-patches-ow...@gcc.gnu.org [mailto:gcc-patches- > ow...@gcc.gnu.org] On Behalf Of Thomas Preud'homme > > From: Steven Bosscher [mailto:stevenb....@gmail.com] > > Sent: Tuesday, May 19, 2015 7:21 PM > > > > Not OK. > > This will break in move_invariants() when it looks at REGNO (inv->reg). > > Indeed. I'm even surprised all tests passed. Ok I will just prevent moving > in such a case. I'm running the tests now and will get back to you > tomorrow.
Patch is now tested via bootstrap + testsuite run on x86_64-linux-gnu and building arm-none-eabi cross-compiler + testsuite run. Both testsuite run show no regression. diff --git a/gcc/loop-invariant.c b/gcc/loop-invariant.c index 76a009f..4ce3576 100644 --- a/gcc/loop-invariant.c +++ b/gcc/loop-invariant.c @@ -1626,7 +1626,7 @@ move_invariant_reg (struct loop *loop, unsigned invno) if (REG_P (reg)) regno = REGNO (reg); - if (!can_move_invariant_reg (loop, inv, reg)) + if (!can_move_invariant_reg (loop, inv, dest)) { reg = gen_reg_rtx_and_attrs (dest); diff --git a/gcc/testsuite/gcc.c-torture/compile/pr66168.c b/gcc/testsuite/gcc.c-torture/compile/pr66168.c new file mode 100644 index 0000000..d6bfc7b --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/compile/pr66168.c @@ -0,0 +1,15 @@ +int a, b; + +void +fn1 () +{ + for (;;) + { + for (b = 0; b < 3; b++) + { + char e[2]; + char f = e[1]; + a ^= f ? 1 / f : 0; + } + } +} Ok for trunk? Best regards, Thomas