diff options
author | Jakub Jelinek <jakub@redhat.com> | 2006-05-03 13:47:29 +0000 |
---|---|---|
committer | Jakub Jelinek <jakub@redhat.com> | 2006-05-03 13:47:29 +0000 |
commit | f07ea6a00efffcd4265decbef5b3dcabac0f4448 (patch) | |
tree | f418e3a47bc5c55e10816d515d5eda7b57dce92e | |
parent | 9bb9ab146576ab711c5191e52a455d7e2bd3113a (diff) |
svn merge -r113416:113489 svn+ssh://gcc.gnu.org/svn/gcc/branches/gcc-4_1-branch
git-svn-id: https://gcc.gnu.org/svn/gcc/branches/redhat/gcc-4_1-branch@113496 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r-- | gcc/ChangeLog | 32 | ||||
-rw-r--r-- | gcc/DATESTAMP | 2 | ||||
-rw-r--r-- | gcc/c-typeck.c | 13 | ||||
-rw-r--r-- | gcc/config/arm/arm.c | 33 | ||||
-rw-r--r-- | gcc/config/arm/vfp.md | 4 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 16 | ||||
-rw-r--r-- | gcc/testsuite/gcc.c-torture/execute/pr27364.c | 13 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/large-size-array-2.c | 7 | ||||
-rw-r--r-- | gcc/testsuite/gcc.target/arm/arm.exp | 41 | ||||
-rw-r--r-- | gcc/testsuite/gcc.target/arm/pr27387.C | 26 | ||||
-rw-r--r-- | gcc/tree-vrp.c | 24 |
11 files changed, 199 insertions, 12 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 4523a5bb6f7..31641362a12 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,35 @@ +2006-05-02 Jeff Law <law@redhat.com> + + PR tree-optimization/27364 + * tree-vrp.c (vrp_int_const_binop): Fix detection of overflow from + multiply expressions. + +2006-05-02 Roger Sayle <roger@eyesopen.com> + + PR c/25309 + * c-typeck.c (struct spelling): Make I an unsigned HOST_WIDE_INT. + (push_array_bounds): Delete prototype. Change BOUNDS argument to + an unsigned HOST_WIDE_INT. + (print_spelling): Use HOST_WIDE_INT_PRINT_UNSIGNED to output the + array index. + (really_start_incremental_init): No need to call convert because + bitsize_zero_node is already of type bitsizetype. + (push_init_level): Extract the value of constructor_index as an + unsigned HOST_WIDE_INT quantity, using tree_low_cst. + (process_init_element): Likewise. + +2006-05-02 Kazu Hirata <kazu@codesourcery.com> + + PR target/27387 + * arm.c (arm_output_mi_thunk): Use pc-relative addressing when + -mthumb -fPIC are used. + +2006-05-01 Kazu Hirata <kazu@codesourcery.com> + + PR target/27374 + * config/arm/vfp.md (*arm_movdi_vfp): Correct the output + templates for case 3 and 4. + 2006-05-03 Jakub Jelinek <jakub@redhat.com> PR fortran/27395 diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP index 1a428314441..ab373dd97cb 100644 --- a/gcc/DATESTAMP +++ b/gcc/DATESTAMP @@ -1 +1 @@ -20060501 +20060503 diff --git a/gcc/c-typeck.c b/gcc/c-typeck.c index 15cf10fb19a..594c441a195 100644 --- a/gcc/c-typeck.c +++ b/gcc/c-typeck.c @@ -88,7 +88,6 @@ static tree convert_for_assignment (tree, tree, enum impl_conv, tree, tree, static tree valid_compound_expr_initializer (tree, tree); static void push_string (const char *); static void push_member_name (tree); -static void push_array_bounds (int); static int spelling_length (void); static char *print_spelling (char *); static void warning_init (const char *); @@ -4235,7 +4234,7 @@ struct spelling int kind; union { - int i; + unsigned HOST_WIDE_INT i; const char *s; } u; }; @@ -4295,7 +4294,7 @@ push_member_name (tree decl) /* Push an array bounds on the stack. Printed as [BOUNDS]. */ static void -push_array_bounds (int bounds) +push_array_bounds (unsigned HOST_WIDE_INT bounds) { PUSH_SPELLING (SPELLING_BOUNDS, bounds, u.i); } @@ -4330,7 +4329,7 @@ print_spelling (char *buffer) for (p = spelling_base; p < spelling; p++) if (p->kind == SPELLING_BOUNDS) { - sprintf (d, "[%d]", p->u.i); + sprintf (d, "[" HOST_WIDE_INT_PRINT_UNSIGNED "]", p->u.i); d += strlen (d); } else @@ -5009,7 +5008,7 @@ really_start_incremental_init (tree type) /* Vectors are like simple fixed-size arrays. */ constructor_max_index = build_int_cst (NULL_TREE, TYPE_VECTOR_SUBPARTS (constructor_type) - 1); - constructor_index = convert (bitsizetype, bitsize_zero_node); + constructor_index = bitsize_zero_node; constructor_unfilled_index = constructor_index; } else @@ -5126,7 +5125,7 @@ push_init_level (int implicit) else if (TREE_CODE (constructor_type) == ARRAY_TYPE) { constructor_type = TREE_TYPE (constructor_type); - push_array_bounds (tree_low_cst (constructor_index, 0)); + push_array_bounds (tree_low_cst (constructor_index, 1)); constructor_depth++; } @@ -6521,7 +6520,7 @@ process_init_element (struct c_expr value) /* Now output the actual element. */ if (value.value) { - push_array_bounds (tree_low_cst (constructor_index, 0)); + push_array_bounds (tree_low_cst (constructor_index, 1)); output_init_element (value.value, strict_string, elttype, constructor_index, 1); RESTORE_SPELLING_DEPTH (constructor_depth); diff --git a/gcc/config/arm/arm.c b/gcc/config/arm/arm.c index 0bf6e4820e4..a47f3a12f5e 100644 --- a/gcc/config/arm/arm.c +++ b/gcc/config/arm/arm.c @@ -14634,6 +14634,7 @@ arm_output_mi_thunk (FILE *file, tree thunk ATTRIBUTE_UNUSED, { static int thunk_label = 0; char label[256]; + char labelpc[256]; int mi_delta = delta; const char *const mi_op = mi_delta < 0 ? "sub" : "add"; int shift = 0; @@ -14648,6 +14649,23 @@ arm_output_mi_thunk (FILE *file, tree thunk ATTRIBUTE_UNUSED, fputs ("\tldr\tr12, ", file); assemble_name (file, label); fputc ('\n', file); + if (flag_pic) + { + /* If we are generating PIC, the ldr instruction below loads + "(target - 7) - .LTHUNKPCn" into r12. The pc reads as + the address of the add + 8, so we have: + + r12 = (target - 7) - .LTHUNKPCn + (.LTHUNKPCn + 8) + = target + 1. + + Note that we have "+ 1" because some versions of GNU ld + don't set the low bit of the result for R_ARM_REL32 + relocations against thumb function symbols. */ + ASM_GENERATE_INTERNAL_LABEL (labelpc, "LTHUNKPC", labelno); + assemble_name (file, labelpc); + fputs (":\n", file); + fputs ("\tadd\tr12, pc, r12\n", file); + } } while (mi_delta != 0) { @@ -14668,7 +14686,20 @@ arm_output_mi_thunk (FILE *file, tree thunk ATTRIBUTE_UNUSED, ASM_OUTPUT_ALIGN (file, 2); assemble_name (file, label); fputs (":\n", file); - assemble_integer (XEXP (DECL_RTL (function), 0), 4, BITS_PER_WORD, 1); + if (flag_pic) + { + /* Output ".word .LTHUNKn-7-.LTHUNKPCn". */ + rtx tem = XEXP (DECL_RTL (function), 0); + tem = gen_rtx_PLUS (GET_MODE (tem), tem, GEN_INT (-7)); + tem = gen_rtx_MINUS (GET_MODE (tem), + tem, + gen_rtx_SYMBOL_REF (Pmode, + ggc_strdup (labelpc))); + assemble_integer (tem, 4, BITS_PER_WORD, 1); + } + else + /* Output ".word .LTHUNKn". */ + assemble_integer (XEXP (DECL_RTL (function), 0), 4, BITS_PER_WORD, 1); } else { diff --git a/gcc/config/arm/vfp.md b/gcc/config/arm/vfp.md index 5809a4531ed..7608217a77b 100644 --- a/gcc/config/arm/vfp.md +++ b/gcc/config/arm/vfp.md @@ -158,9 +158,9 @@ case 2: return output_move_double (operands); case 3: - return \"fmdrr%?\\t%P0, %1\\t%@ int\"; + return \"fmdrr%?\\t%P0, %Q1, %R1\\t%@ int\"; case 4: - return \"fmrrd%?\\t%0, %1\\t%@ int\"; + return \"fmrrd%?\\t%Q0, %R0, %P1\\t%@ int\"; case 5: return \"fcpyd%?\\t%P0, %P1\\t%@ int\"; case 6: diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index b6e2cb3733c..c1bcf8ea8c6 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,19 @@ +2006-05-02 Jeff Law <law@redhat.com> + + PR tree-optimization/27364 + * gcc.c-torture/execute/pr27364.c: New test. + +2006-05-02 Roger Sayle <roger@eyesopen.com> + + PR c/25309 + * gcc.dg/large-size-array-2.c: New test case. + +2006-05-02 Kazu Hirata <kazu@codesourcery.com> + + PR target/27387 + * gcc.target/arm/arm.exp: New. + * gcc.target/arm/pr27387.C: Likewise. + 2006-05-02 Jakub Jelinek <jakub@redhat.com> PR middle-end/27337 diff --git a/gcc/testsuite/gcc.c-torture/execute/pr27364.c b/gcc/testsuite/gcc.c-torture/execute/pr27364.c new file mode 100644 index 00000000000..aa608b2a2fe --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/pr27364.c @@ -0,0 +1,13 @@ +int f(unsigned number_of_digits_to_use) +{ + if (number_of_digits_to_use >1294) + return 0; + return (number_of_digits_to_use * 3321928 / 1000000 + 1) /16; +} + +int main(void) +{ + if (f(11) != 2) + __builtin_abort (); + exit (0); +} diff --git a/gcc/testsuite/gcc.dg/large-size-array-2.c b/gcc/testsuite/gcc.dg/large-size-array-2.c new file mode 100644 index 00000000000..6ac31d11af4 --- /dev/null +++ b/gcc/testsuite/gcc.dg/large-size-array-2.c @@ -0,0 +1,7 @@ +/* PR c/25309 */ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ +static char * name[] = { + [0x80000000] = "bar" + }; + diff --git a/gcc/testsuite/gcc.target/arm/arm.exp b/gcc/testsuite/gcc.target/arm/arm.exp new file mode 100644 index 00000000000..7f4958e92ac --- /dev/null +++ b/gcc/testsuite/gcc.target/arm/arm.exp @@ -0,0 +1,41 @@ +# Copyright (C) 1997, 2004, 2006 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + +# GCC testsuite that uses the `dg.exp' driver. + +# Exit immediately if this isn't an ARM target. +if ![istarget arm*-*-*] then { + return +} + +# Load support procs. +load_lib gcc-dg.exp + +# If a testcase doesn't have special options, use these. +global DEFAULT_CFLAGS +if ![info exists DEFAULT_CFLAGS] then { + set DEFAULT_CFLAGS " -ansi -pedantic-errors" +} + +# Initialize `dg'. +dg-init + +# Main loop. +dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.\[cCS\]]] \ + "" $DEFAULT_CFLAGS + +# All done. +dg-finish diff --git a/gcc/testsuite/gcc.target/arm/pr27387.C b/gcc/testsuite/gcc.target/arm/pr27387.C new file mode 100644 index 00000000000..5ffce10ba11 --- /dev/null +++ b/gcc/testsuite/gcc.target/arm/pr27387.C @@ -0,0 +1,26 @@ +/* PR target/90000 + We used to generate a non-PIC thunk on thumb even with -fPIC. + Make sure that won't happen anymore. */ + +/* { dg-do compile } */ +/* { dg-require-effective-target arm32 } */ +/* { dg-options "-mthumb -fPIC" } */ + +struct A { + virtual void f (); +}; + +struct B { + virtual void g (); +}; + +struct C : public A, public B { + virtual void g(); +}; + +void +C::g() +{ +} + +/* { dg-final { scan-assembler "LTHUNKPC" } } */ diff --git a/gcc/tree-vrp.c b/gcc/tree-vrp.c index a94016c7d3e..59631e6be53 100644 --- a/gcc/tree-vrp.c +++ b/gcc/tree-vrp.c @@ -1101,17 +1101,39 @@ vrp_int_const_binop (enum tree_code code, tree val1, tree val2) if (TYPE_UNSIGNED (TREE_TYPE (val1))) { int checkz = compare_values (res, val1); + bool overflow = false; /* Ensure that res = val1 [+*] val2 >= val1 or that res = val1 - val2 <= val1. */ - if (((code == PLUS_EXPR || code == MULT_EXPR) + if ((code == PLUS_EXPR && !(checkz == 1 || checkz == 0)) || (code == MINUS_EXPR && !(checkz == 0 || checkz == -1))) { + overflow = true; + } + /* Checking for multiplication overflow is done by dividing the + output of the multiplication by the first input of the + multiplication. If the result of that division operation is + not equal to the second input of the multiplication, then the + multiplication overflowed. */ + else if (code == MULT_EXPR && !integer_zerop (val1)) + { + tree tmp = int_const_binop (TRUNC_DIV_EXPR, + TYPE_MAX_VALUE (TREE_TYPE (val1)), + val1, 0); + int check = compare_values (tmp, val2); + + if (check != 0) + overflow = true; + } + + if (overflow) + { res = copy_node (res); TREE_OVERFLOW (res) = 1; } + } else if (TREE_OVERFLOW (res) && !TREE_OVERFLOW (val1) |