From: olga Date: Mon, 21 Jan 2008 09:07:12 +0000 (+0000) Subject: 2008-01-21 Alon Dayan X-Git-Tag: upstream/4.9.2~44075 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=f25ba2cf7d7b1ff2e3ad85d3d4454f9a266b59f1;p=platform%2Fupstream%2Flinaro-gcc.git 2008-01-21 Alon Dayan Olga Golovanevsky PR tree-optimization/34701 * gcc.dg/struct/wo_prof_array_field.c: New test. 2008-01-21 Alon Dayan Olga Golovanevsky PR tree-optimization/34701 * ipa-struct-reorg.c (gen_size): Fix the malloc parameter calculation when the structure size is not a power of 2. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@131689 138bc75d-0d04-0410-961f-82ee72b054a4 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index f061381..28474ddf 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,10 @@ +2008-01-21 Alon Dayan + Olga Golovanevsky + + PR tree-optimization/34701 + * ipa-struct-reorg.c (gen_size): Fix the malloc parameter calculation + when the structure size is not a power of 2. + 2008-01-20 Kenneth Zadeck * doc/install.texi: Add doc for --enable-checking=df. diff --git a/gcc/ipa-struct-reorg.c b/gcc/ipa-struct-reorg.c index be60a21..0619576 100644 --- a/gcc/ipa-struct-reorg.c +++ b/gcc/ipa-struct-reorg.c @@ -623,7 +623,12 @@ gen_size (tree num, tree type, tree *res) add_referenced_var (*res); if (exact_log2 (struct_size_int) == -1) - new_stmt = build_gimple_modify_stmt (num, struct_size); + { + tree size = build_int_cst (TREE_TYPE (num), struct_size_int); + new_stmt = build_gimple_modify_stmt (*res, build2 (MULT_EXPR, + TREE_TYPE (num), + num, size)); + } else { tree C = build_int_cst (TREE_TYPE (num), exact_log2 (struct_size_int)); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index f3e4f01..1fda4f9 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2008-01-21 Alon Dayan + Olga Golovanevsky + + PR tree-optimization/34701 + * gcc.dg/struct/wo_prof_array_field.c: New test. + 2008-01-20 Paolo Carlini PR c++/34891 diff --git a/gcc/testsuite/gcc.dg/struct/wo_prof_array_field.c b/gcc/testsuite/gcc.dg/struct/wo_prof_array_field.c new file mode 100644 index 0000000..1c41de5 --- /dev/null +++ b/gcc/testsuite/gcc.dg/struct/wo_prof_array_field.c @@ -0,0 +1,27 @@ +/* { dg-do compile } */ +/* { dg-do run } */ + +#include +typedef struct basic +{ + int a; + int b[10]; +} type_struct; + +type_struct *str1; + +int main() +{ + int i; + + str1 = malloc (10 * sizeof (type_struct)); + + for (i=0; i<=9; i++) + str1[i].a = str1[i].b[0]; + + return 0; +} + +/*--------------------------------------------------------------------------*/ +/* { dg-final { scan-ipa-dump "Number of structures to transform is 1" "ipa_struct_reorg" } } */ +/* { dg-final { cleanup-ipa-dump "*" } } */