From b45f0e58d72a6ea2f54d007152b55fc44311359f Mon Sep 17 00:00:00 2001 From: Paolo Bonzini Date: Thu, 9 Apr 2009 16:07:43 +0000 Subject: [PATCH] expmed.c (expand_divmod): Always use a comparison for a division by a large unsigned integer. 2009-04-09 Paolo Bonzini * expmed.c (expand_divmod): Always use a comparison for a division by a large unsigned integer. * fold-const.c (tree_single_nonzero_warnv_p): Always treat decls for things others than variables or functions as nonzero. testsuite: 2009-04-09 Paolo Bonzini * gcc.dg/pr27150-1.c: Change to a link test. From-SVN: r145846 --- gcc/ChangeLog | 43 ++++++++++++++++++++++++++++++++ gcc/expmed.c | 6 ++--- gcc/fold-const.c | 4 +-- gcc/testsuite/ChangeLog | 4 +++ gcc/testsuite/gcc.dg/pr27150-1.c | 11 ++++++-- 5 files changed, 60 insertions(+), 8 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 529286f322e..90e7b113880 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,11 @@ +2009-04-09 Paolo Bonzini + + * expmed.c (expand_divmod): Always use a comparison for a division + by a large unsigned integer. + + * fold-const.c (tree_single_nonzero_warnv_p): Always treat decls + for things others than variables or functions as nonzero. + 2009-04-09 Nick Clifton * unwind-compat.c: Change copyright header to refer to version @@ -338,6 +346,41 @@ 2009-04-09 Paolo Bonzini + * config/i386/i386.md (cmpcc): New. + * config/i386/sync.md (sync_compare_and_swap*): Set FLAGS_REG. + (sync_compare_and_swap_cc*): Delete. + + * config/s390/s390.c (s390_compare_emitted): Remove. + (s390_emit_compare): Handle MODE_CC s390_compare_op0 like + s390_compare_emitted used to be handled. Assert that modes match. + (s390_emit_compare_and_swap): Use s390_emit_compare, do not + refer to sync_compare_and_swap_ccsi. + * config/s390/s390.h (s390_compare_emitted): Remove. + * config/s390/s390.md (seq): Look for MODE_CC s390_compare_op0 + instead of s390_compare_emitted. + (stack_protect_test, sync_compare_and_swap_cc): Set s390_compare_op0 + instead of s390_compare_emitted. + * config/s390/s390.md (cmpcc): New. + (sync_compare_and_swapqi, sync_compare_and_swaphi): Clobber + CC_REGNUM, do not pretend it's set. + (sync_compare_and_swap_cc*): Delete. + * config/s390/predicates.md (cc_reg_operand): New. + + * expr.c (sync_compare_and_swap_cc): Delete. + * optabs.h (sync_compare_and_swap_cc): Delete. + * optabs.c (prepare_cmp_insn): Ignore which specific CCmode + is being used with can_compare_p. + (emit_cmp_and_jump_insn_1): Likewise when looking in the optab. + (find_cc_set): New. + (expand_bool_compare_and_swap): Do not use sync_compare_and_swap_cc, + look for a MODE_CC set instead. Use emit_store_flag. + (expand_compare_and_swap_loop): Likewise, with some additional + complication to avoid a force_reg when useless. Use + emit_cmp_and_jump_insns. + * genopinit.c (optabs): Delete sync_compare_and_swap_cc. + * doc/md.texi (sync_compare_and_swap_cc): Merge with + sync_compare_and_swap documentation. +======= * config/i386/i386.md (cmpcc): New. * config/i386/sync.md (sync_compare_and_swap*): Set FLAGS_REG. (sync_compare_and_swap_cc*): Delete. diff --git a/gcc/expmed.c b/gcc/expmed.c index da0db3b8347..165bcaea09e 100644 --- a/gcc/expmed.c +++ b/gcc/expmed.c @@ -3998,10 +3998,8 @@ expand_divmod (int rem_flag, enum tree_code code, enum machine_mode mode, { /* Most significant bit of divisor is set; emit an scc insn. */ - quotient = emit_store_flag (tquotient, GEU, op0, op1, - compute_mode, 1, 1); - if (quotient == 0) - goto fail1; + quotient = emit_store_flag_force (tquotient, GEU, op0, op1, + compute_mode, 1, 1); } else { diff --git a/gcc/fold-const.c b/gcc/fold-const.c index 7dcf993269d..821e581348a 100644 --- a/gcc/fold-const.c +++ b/gcc/fold-const.c @@ -15018,8 +15018,8 @@ tree_single_nonzero_warnv_p (tree t, bool *strict_overflow_p) return false; /* Weak declarations may link to NULL. */ - if (VAR_OR_FUNCTION_DECL_P (base)) - return !DECL_WEAK (base); + if (DECL_P (base) && flag_delete_null_pointer_checks) + return !VAR_OR_FUNCTION_DECL_P (base) || !DECL_WEAK (base); /* Constants are never weak. */ if (CONSTANT_CLASS_P (base)) diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index ed0bc4b6285..145880d5f4d 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2009-04-09 Paolo Bonzini + + * gcc.dg/pr27150-1.c: Change to a link test. + 2009-04-09 Jakub Jelinek * g++.dg/lookup/using2.C: Change copyright header to refer to version diff --git a/gcc/testsuite/gcc.dg/pr27150-1.c b/gcc/testsuite/gcc.dg/pr27150-1.c index 03810cd7e15..5a00cf9f90f 100644 --- a/gcc/testsuite/gcc.dg/pr27150-1.c +++ b/gcc/testsuite/gcc.dg/pr27150-1.c @@ -1,7 +1,14 @@ -/* { dg-do compile } */ +/* { dg-do link } */ /* { dg-options "-O2" } */ +extern int link_error (); int g(int f) { - return (&f)!=0; + int a = ((&f)!=0); + if (!a) link_error (); + return a; } +int main() +{ + g(10); +}