[Bug tree-optimization/91597] [9/10 Regression] GCC miscompiles a branch depending on a pointer tag

2019-09-03 Thread jakub at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91597

Jakub Jelinek  changed:

   What|Removed |Added

 Status|NEW |RESOLVED
 Resolution|--- |FIXED

--- Comment #6 from Jakub Jelinek  ---
Fixed.

[Bug tree-optimization/91597] [9/10 Regression] GCC miscompiles a branch depending on a pointer tag

2019-09-03 Thread jakub at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91597

--- Comment #5 from Jakub Jelinek  ---
Author: jakub
Date: Tue Sep  3 16:55:31 2019
New Revision: 275345

URL: https://gcc.gnu.org/viewcvs?rev=275345=gcc=rev
Log:
PR tree-optimization/91597
* tree-vrp.c (extract_range_from_binary_expr): Remove unsafe
BIT_AND_EXPR optimization for pointers, even if both operand
ranges don't include NULL, the result can be NULL.

* gcc.c-torture/execute/pr91597.c: New test.

Added:
branches/gcc-9-branch/gcc/testsuite/gcc.c-torture/execute/pr91597.c
Modified:
branches/gcc-9-branch/gcc/ChangeLog
branches/gcc-9-branch/gcc/testsuite/ChangeLog
branches/gcc-9-branch/gcc/tree-vrp.c

[Bug tree-optimization/91597] [9/10 Regression] GCC miscompiles a branch depending on a pointer tag

2019-09-03 Thread jakub at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91597

--- Comment #4 from Jakub Jelinek  ---
Author: jakub
Date: Tue Sep  3 07:50:46 2019
New Revision: 275330

URL: https://gcc.gnu.org/viewcvs?rev=275330=gcc=rev
Log:
PR tree-optimization/91597
* tree-vrp.c (extract_range_from_binary_expr): Remove unsafe
BIT_AND_EXPR optimization for pointers, even if both operand
ranges don't include NULL, the result can be NULL.

* gcc.c-torture/execute/pr91597.c: New test.

Added:
trunk/gcc/testsuite/gcc.c-torture/execute/pr91597.c
Modified:
trunk/gcc/ChangeLog
trunk/gcc/testsuite/ChangeLog
trunk/gcc/tree-vrp.c

[Bug tree-optimization/91597] [9/10 Regression] GCC miscompiles a branch depending on a pointer tag

2019-08-29 Thread wjnawrocki at protonmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91597

--- Comment #3 from Wojciech Nawrocki  ---
Workaround: -fdisable-tree-ifcombine turns off the broken optimization pass

[Bug tree-optimization/91597] [9/10 Regression] GCC miscompiles a branch depending on a pointer tag

2019-08-29 Thread jakub at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91597

--- Comment #2 from Jakub Jelinek  ---
As mentioned by Richi,
  else if (code == BIT_AND_EXPR)
{
  /* For pointer types, we are really only interested in asserting
 whether the expression evaluates to non-NULL.  */
  if (!range_includes_zero_p () && !range_includes_zero_p ())
vr->set_nonzero (expr_type);
is incorrect, even when both pointer value ranges are non-zero, the result of
BIT_AND_EXPR can be zero, as can be seen on this testcase.  The first argument
being non-NULL as dereferenced, the other argument constant 1B, the pointer
aligned and thus actually & 1 always zero, not always non-zero, but even if it
would not be always aligned, it could be sometimes zero and sometimes not.

[Bug tree-optimization/91597] [9/10 Regression] GCC miscompiles a branch depending on a pointer tag

2019-08-29 Thread jakub at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91597

Jakub Jelinek  changed:

   What|Removed |Added

 Status|UNCONFIRMED |NEW
   Last reconfirmed||2019-08-29
 CC||jakub at gcc dot gnu.org
   Target Milestone|--- |9.3
 Ever confirmed|0   |1

--- Comment #1 from Jakub Jelinek  ---
Started with r263842, likely latent before that.