The following fixes a very old bug in RTL nonzero_address_p which fails
to consider -fno-delete-null-pointer-checks.  Fixing that makes the
testcase

extern unsigned int _vector_table;

int main(void)
{
  unsigned int *vector_base = &_vector_table;

  if (vector_base == 0) {
      return 1;
  } else {
      return 2;
  }
}

not optimize the check with that flag.  We appearantly never got this
right, so I'll install this on trunk only.

Bootstrap & regtest running on x86_64-unknown-linux-gnu.

Richard.

2015-09-21  Richard Biener  <rguent...@suse.de>

        PR middle-end/67651
        * rtlanal.c (nonzero_address_p): SYMBOL_REFs may have zero
        address with -fno-delete-null-pointer-checks.

Index: gcc/rtlanal.c
===================================================================
--- gcc/rtlanal.c       (revision 227899)
+++ gcc/rtlanal.c       (working copy)
@@ -723,7 +723,7 @@ nonzero_address_p (const_rtx x)
   switch (code)
     {
     case SYMBOL_REF:
-      return !SYMBOL_REF_WEAK (x);
+      return flag_delete_null_pointer_checks && !SYMBOL_REF_WEAK (x);
 
     case LABEL_REF:
       return true;

Reply via email to