This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Fix type mismatch created by DOM (PR 22335)


There are two issues here, the first is in lookup_avail_expr dealing with null pointer
elimination where we return a boolean type instead of the correct type for the
conditional expression. The reason why VRP does not catch this is because we
run VRP too early before SRA has happened.


The second issue here is that in eliminate_redundant_computations, we forget
to convert the if the conversion is needed (from void* to any thing for an example).


This patch fixes both of those issues.  Both of these issues show up in
bootstrapping with the patch in PR 22368.

OK? Bootstraped and tested on powerpc-darwin with no regressions.

Thanks,
Andrew Pinski

ChangeLog:
* tree-ssa-dom.c (lookup_avail_expr): Use constant_boolean_node instead
of boolean_false_node/boolean_true_node.
(eliminate_redundant_computations): Convert the cached_lhs to the correct type
if needed.


Attachment: dom.diff.txt
Description: Text document



Testcases:
testcase1:
/* { dg-do compile } */
/* { dg-options "-O1 -fdelete-null-pointer-checks"  } */
int t(int *a)
{
  int i;
  *a = 1;
  i = a == 0;
  return i;
}

testcase2:
/* { dg-do compile } */
/* { dg-options "-O2"  } */
void abort(void) __attribute__((__noreturn__));
typedef struct {
  int container;
} edge_iterator;
struct ls_expr
{
  int index;
  int stores;
  struct ls_expr * next;
};
struct ls_expr * pre_ldst_mems;
edge_iterator ei;
void
store_motion (void)
{
  struct ls_expr * ptr, **prev_next_ptr_ptr;
  edge_iterator ei1;
  edge_iterator ei2;
  int a = ptr != ((void *)0);
  for (ptr = pre_ldst_mems, prev_next_ptr_ptr = &pre_ldst_mems;
       ptr != ((void *)0);
       ptr = *prev_next_ptr_ptr)
    if (!((ptr)->stores))
     *prev_next_ptr_ptr = ptr->next;
    else
      prev_next_ptr_ptr = &ptr->next;

  for (ptr = pre_ldst_mems; ptr != 0; ptr = ptr->next)
    ;
  ei1 = ei;
  ei2 = ei1;
  if (!ei2.container)
    abort ();
  ei2 = ei1;
  if (!ei2.container)
    abort ();
}

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]