[Bug tree-optimization/84982] [8 Regression] logically inverting bools into local array results in bitwise negation

2018-03-20 Thread rguenth at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84982

Richard Biener  changed:

   What|Removed |Added

   Priority|P3  |P1
 Status|UNCONFIRMED |NEW
   Keywords||wrong-code
   Last reconfirmed||2018-03-20
  Component|c   |tree-optimization
 CC||jakub at gcc dot gnu.org
 Ever confirmed|0   |1
Summary|logically inverting bools   |[8 Regression] logically
   |into local array results in |inverting bools into local
   |bitwise negation|array results in bitwise
   ||negation
   Target Milestone|--- |8.0

--- Comment #1 from Richard Biener  ---
Confirmed.  store-merging at play.

@@ -8,14 +12,17 @@
   _Bool _2;
   _Bool _3;
   _Bool _4;
+  unsigned short _11;
+  unsigned short _12;

[local count: 1073741825]:
   _1 = t_6(D)->a;
   _2 = ~_1;
-  flags[0] = _2;
   _3 = t_6(D)->b;
   _4 = ~_3;
-  flags[1] = _4;
+  _11 = MEM[(_Bool *)t_6(D)];
+  _12 = ~_11;
+  MEM[(_Bool *)&flags] = _12;

[Bug tree-optimization/84982] [8 Regression] logically inverting bools into local array results in bitwise negation

2018-03-20 Thread jakub at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84982

Jakub Jelinek  changed:

   What|Removed |Added

 Status|NEW |ASSIGNED
   Assignee|unassigned at gcc dot gnu.org  |jakub at gcc dot gnu.org

[Bug tree-optimization/84982] [8 Regression] logically inverting bools into local array results in bitwise negation

2018-03-20 Thread jakub at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84982

--- Comment #2 from Jakub Jelinek  ---
Created attachment 43719
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=43719&action=edit
gcc8-pr84982.patch

Untested fix.

[Bug tree-optimization/84982] [8 Regression] logically inverting bools into local array results in bitwise negation

2018-03-21 Thread jakub at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84982

--- Comment #3 from Jakub Jelinek  ---
Author: jakub
Date: Wed Mar 21 20:20:40 2018
New Revision: 258742

URL: https://gcc.gnu.org/viewcvs?rev=258742&root=gcc&view=rev
Log:
PR tree-optimization/84982
* gimple-ssa-store-merging.c (invert_op): Handle boolean inversion
by flipping the least significant bit rather than all bits from
bitpos to bitpos + bitsize - 1.

* c-c++-common/pr84982.c: New test.

Added:
trunk/gcc/testsuite/c-c++-common/pr84982.c
Modified:
trunk/gcc/ChangeLog
trunk/gcc/gimple-ssa-store-merging.c
trunk/gcc/testsuite/ChangeLog

[Bug tree-optimization/84982] [8 Regression] logically inverting bools into local array results in bitwise negation

2018-03-21 Thread jakub at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84982

Jakub Jelinek  changed:

   What|Removed |Added

 Status|ASSIGNED|RESOLVED
 Resolution|--- |FIXED

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