From: Zdenek Dvorak Date: Fri, 12 Oct 2007 22:26:47 +0000 (+0200) Subject: re PR middle-end/33714 (ivopts miscompiles insn-output.c) X-Git-Tag: prereleases/gcc-4.2.3-rc1~192 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=382bdc19aca3a47f22318b490385d567ef3aa5f3;p=thirdparty%2Fgcc.git re PR middle-end/33714 (ivopts miscompiles insn-output.c) PR tree-optimization/33714 * tree-ssa-loop-ivopts.c (constant_multiple_of): Pass the arguments to division in the correct order. * gcc.dg/tree-ssa/pr33714.c: New test. From-SVN: r129277 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index c5a4319df779..710fa5b724e0 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2007-10-12 Zdenek Dvorak + + PR tree-optimization/33714 + * tree-ssa-loop-ivopts.c (constant_multiple_of): Pass the arguments to + division in the correct order. + 2007-10-10 Joseph Myers PR c/25309 diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 71474bb1ec19..7ffdf38aec72 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2007-10-12 Zdenek Dvorak + + PR tree-optimization/33714 + * gcc.dg/tree-ssa/pr33714.c: New test. + 2007-10-10 Joseph Myers PR c/25309 diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr33714.c b/gcc/testsuite/gcc.dg/tree-ssa/pr33714.c new file mode 100644 index 000000000000..837bc8d6acb7 --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa/pr33714.c @@ -0,0 +1,59 @@ +/* { dg-do run } */ +/* { dg-options "-O2" } */ + +struct rtx_def +{ + int mode : 8; + union { + long long hwint[1]; + } u; +}; +typedef struct rtx_def *rtx; + +void useme (long long int i) __attribute__((noinline)); +void do_something (void *) __attribute__((noinline)); +rtx get_rtx (int) __attribute__((noinline)); +void output_766 (rtx *operands,int) __attribute__((noinline)); + +int target_flags; + +int global_count; +void useme (long long int i __attribute__((unused))) +{ + global_count++; +} + +rtx get_rtx (int i) { return i?0:0; } +void do_something (void *p __attribute__((unused))) { global_count++;} + +void +output_766 (rtx *operands, int ival) +{ + int i; + for (i = ival; i >= ((operands[2])->u.hwint[0]); i--) + { + useme(i*16); + operands[5] = get_rtx (i <= 7 ? i+1 : i+2); + operands[4]->mode = 15; + do_something (operands); + } +} + +extern void abort(void); +int main(void) +{ + rtx operands[6]; + struct rtx_def rtx2, rtx4; + target_flags = 1 << 2; + operands[0] = 0; + operands[1] = 0; + operands[3] = 0; + operands[5] = 0; + operands[2] = &rtx2; + operands[4] = &rtx4; + rtx2.u.hwint[0] = 0; + output_766 (operands, 7); + if (global_count != 16) + abort(); + return 0; +} diff --git a/gcc/tree-ssa-loop-ivopts.c b/gcc/tree-ssa-loop-ivopts.c index de84fa57d547..87f94e606eda 100644 --- a/gcc/tree-ssa-loop-ivopts.c +++ b/gcc/tree-ssa-loop-ivopts.c @@ -2608,8 +2608,8 @@ constant_multiple_of (tree top, tree bot, double_int *mul) if (TREE_CODE (bot) != INTEGER_CST) return false; - p0 = double_int_sext (tree_to_double_int (bot), precision); - p1 = double_int_sext (tree_to_double_int (top), precision); + p0 = double_int_sext (tree_to_double_int (top), precision); + p1 = double_int_sext (tree_to_double_int (bot), precision); if (double_int_zero_p (p1)) return false; *mul = double_int_sext (double_int_sdivmod (p0, p1, FLOOR_DIV_EXPR, &res),