From 5f2e30efbeb6f361e414de35e7ae9ec5165ff009 Mon Sep 17 00:00:00 2001 From: Joseph Myers Date: Fri, 2 Dec 2011 16:54:27 +0000 Subject: [PATCH] Revert: 2008-09-18 Andrew Pinski PR rtl-opt/37451 * loop-doloop.c (doloop_modify): New argument zero_extend_p and zero extend count after the correction to it is done. (doloop_optimize): Update call to doloop_modify, don't zero extend count before call. 2008-11-03 Andrew Pinski PR rtl-opt/37782 * loop-doloop.c (doloop_modify): Add from_mode argument that says what mode count is in. (doloop_optimize): Update call to doloop_modify. testsuite: * gcc.c-torture/execute/doloop-1.c, gcc.c-torture/execute/doloop-2.c: New tests. From-SVN: r181929 --- gcc/ChangeLog | 19 ++++++++++++++++++ gcc/loop-doloop.c | 20 ++++++------------- gcc/testsuite/ChangeLog | 5 +++++ .../gcc.c-torture/execute/doloop-1.c | 18 +++++++++++++++++ .../gcc.c-torture/execute/doloop-2.c | 18 +++++++++++++++++ 5 files changed, 66 insertions(+), 14 deletions(-) create mode 100644 gcc/testsuite/gcc.c-torture/execute/doloop-1.c create mode 100644 gcc/testsuite/gcc.c-torture/execute/doloop-2.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 3865341fc245..e53ba2b772f8 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,22 @@ +2011-12-02 Joseph Myers + + Revert: + + 2008-09-18 Andrew Pinski + + PR rtl-opt/37451 + * loop-doloop.c (doloop_modify): New argument zero_extend_p and + zero extend count after the correction to it is done. + (doloop_optimize): Update call to doloop_modify, don't zero extend + count before call. + + 2008-11-03 Andrew Pinski + + PR rtl-opt/37782 + * loop-doloop.c (doloop_modify): Add from_mode argument that says what + mode count is in. + (doloop_optimize): Update call to doloop_modify. + 2011-12-02 Richard Guenther PR lto/47259 diff --git a/gcc/loop-doloop.c b/gcc/loop-doloop.c index a7e264f2c8d9..5f6456941075 100644 --- a/gcc/loop-doloop.c +++ b/gcc/loop-doloop.c @@ -394,14 +394,11 @@ add_test (rtx cond, edge *e, basic_block dest) describes the loop, DESC describes the number of iterations of the loop, and DOLOOP_INSN is the low-overhead looping insn to emit at the end of the loop. CONDITION is the condition separated from the - DOLOOP_SEQ. COUNT is the number of iterations of the LOOP. - ZERO_EXTEND_P says to zero extend COUNT after the increment of it to - word_mode from FROM_MODE. */ + DOLOOP_SEQ. COUNT is the number of iterations of the LOOP. */ static void doloop_modify (struct loop *loop, struct niter_desc *desc, - rtx doloop_seq, rtx condition, rtx count, - bool zero_extend_p, enum machine_mode from_mode) + rtx doloop_seq, rtx condition, rtx count) { rtx counter_reg; rtx tmp, noloop = NULL_RTX; @@ -475,11 +472,7 @@ doloop_modify (struct loop *loop, struct niter_desc *desc, } if (increment_count) - count = simplify_gen_binary (PLUS, from_mode, count, const1_rtx); - - if (zero_extend_p) - count = simplify_gen_unary (ZERO_EXTEND, word_mode, - count, from_mode); + count = simplify_gen_binary (PLUS, mode, count, const1_rtx); /* Insert initialization of the count register into the loop header. */ start_sequence (); @@ -615,7 +608,6 @@ doloop_optimize (struct loop *loop) struct niter_desc *desc; unsigned word_mode_size; unsigned HOST_WIDE_INT word_mode_max; - bool zero_extend_p = false; if (dump_file) fprintf (dump_file, "Doloop: Processing loop %d.\n", loop->num); @@ -690,7 +682,8 @@ doloop_optimize (struct loop *loop) { if (word_mode_size > GET_MODE_PRECISION (mode)) { - zero_extend_p = true; + count = simplify_gen_unary (ZERO_EXTEND, word_mode, + count, mode); iterations = simplify_gen_unary (ZERO_EXTEND, word_mode, iterations, mode); iterations_max = simplify_gen_unary (ZERO_EXTEND, word_mode, @@ -734,8 +727,7 @@ doloop_optimize (struct loop *loop) return false; } - doloop_modify (loop, desc, doloop_seq, condition, count, - zero_extend_p, mode); + doloop_modify (loop, desc, doloop_seq, condition, count); return true; } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 2d3dc33784bc..982cba0bd6b3 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2011-12-02 Joseph Myers + + * gcc.c-torture/execute/doloop-1.c, + gcc.c-torture/execute/doloop-2.c: New tests. + 2011-12-02 Martin Jambor PR tree-optimization/50622 diff --git a/gcc/testsuite/gcc.c-torture/execute/doloop-1.c b/gcc/testsuite/gcc.c-torture/execute/doloop-1.c new file mode 100644 index 000000000000..d2394a62ec26 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/doloop-1.c @@ -0,0 +1,18 @@ +#include + +extern void exit (int); +extern void abort (void); + +volatile unsigned int i; + +int +main (void) +{ + unsigned char z = 0; + + do ++i; + while (--z > 0); + if (i != UCHAR_MAX + 1U) + abort (); + exit (0); +} diff --git a/gcc/testsuite/gcc.c-torture/execute/doloop-2.c b/gcc/testsuite/gcc.c-torture/execute/doloop-2.c new file mode 100644 index 000000000000..f98118002695 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/doloop-2.c @@ -0,0 +1,18 @@ +#include + +extern void exit (int); +extern void abort (void); + +volatile unsigned int i; + +int +main (void) +{ + unsigned short z = 0; + + do ++i; + while (--z > 0); + if (i != USHRT_MAX + 1U) + abort (); + exit (0); +}