[Bug middle-end/86995] [9 regression] c-c++-common/torture/builtin-arith-overflow-17.c etc. FAIL

2018-08-30 Thread vladlazar at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86995

vladlazar at gcc dot gnu.org changed:

   What|Removed |Added

 Status|UNCONFIRMED |RESOLVED
 CC||vladlazar at gcc dot gnu.org
 Resolution|--- |FIXED

--- Comment #8 from vladlazar at gcc dot gnu.org ---
Fixed by r263973. The issue was that in case of underflow, the overflow flag
was not set. The solution was to use wi::sub when decrementing.

[Bug middle-end/86995] [9 regression] c-c++-common/torture/builtin-arith-overflow-17.c etc. FAIL

2018-08-30 Thread vladlazar at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86995

--- Comment #7 from vladlazar at gcc dot gnu.org ---
Author: vladlazar
Date: Thu Aug 30 09:30:49 2018
New Revision: 263973

URL: https://gcc.gnu.org/viewcvs?rev=263973=gcc=rev
Log:
Enable underflow check in canonicalize_comparison. (PR86995)

gcc/
2018-08-30  Vlad Lazar  

PR middle-end/86995
* expmed.c (canonicalize_comparison): Use wi::sub instead of wi::add
if to_add is negative.


Modified:
trunk/gcc/ChangeLog
trunk/gcc/expmed.c

[Bug middle-end/86995] [9 regression] c-c++-common/torture/builtin-arith-overflow-17.c etc. FAIL

2018-08-29 Thread vlad.lazar at arm dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86995

--- Comment #6 from Vlad Lazar  ---
Here's the patch: https://gcc.gnu.org/ml/gcc-patches/2018-08/msg01889.html

[Bug middle-end/86995] [9 regression] c-c++-common/torture/builtin-arith-overflow-17.c etc. FAIL

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

--- Comment #5 from Jakub Jelinek  ---
Like:
--- gcc/expmed.c.jj 2018-08-26 22:42:22.526779583 +0200
+++ gcc/expmed.c2018-08-29 14:04:32.669509929 +0200
@@ -6239,7 +6239,9 @@ canonicalize_comparison (machine_mode mo
  wrapping around in the case of unsigned values.  If any occur
  cancel the optimization.  */
   wi::overflow_type overflow = wi::OVF_NONE;
-  wide_int imm_modif = wi::add (imm_val, to_add, sgn, );
+  wide_int imm_modif
+= (to_add > 0 ? wi::add (imm_val, 1, sgn, )
+ : wi::sub (imm_val, 1, sgn, ));
   if (overflow)
 return;

If so, please submit it as soon as possible, leaving such important wrong-code
bug for so long is highly undesirable.

[Bug middle-end/86995] [9 regression] c-c++-common/torture/builtin-arith-overflow-17.c etc. FAIL

2018-08-29 Thread vlad.lazar at arm dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86995

--- Comment #4 from Vlad Lazar  ---
That's right. It's not the right fix. The actual cause is the use of wi::add in
r263591, which does not set the flag in case of underflow. The correct way is
to use wi::add for addition and wi::sub for substraction. I'm testing a patch
which does that.

[Bug middle-end/86995] [9 regression] c-c++-common/torture/builtin-arith-overflow-17.c etc. FAIL

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

Jakub Jelinek  changed:

   What|Removed |Added

 CC||jakub at gcc dot gnu.org

--- Comment #3 from Jakub Jelinek  ---
How could a cost adjustment be a right fix to a wrong-code bug?  That seems
just to make it latent.

[Bug middle-end/86995] [9 regression] c-c++-common/torture/builtin-arith-overflow-17.c etc. FAIL

2018-08-23 Thread vlad.lazar at arm dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86995

Vlad Lazar  changed:

   What|Removed |Added

 CC||vlad.lazar at arm dot com

--- Comment #2 from Vlad Lazar  ---
On x86 this was caused by the cost model and has been fixed in r263652.
However, upon further inspection, it surfaced that wi::add does not detect
underflow for unsigned operations. I am currently testing a patch which should
solve the issue.

[Bug middle-end/86995] [9 regression] c-c++-common/torture/builtin-arith-overflow-17.c etc. FAIL

2018-08-22 Thread rguenth at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86995

Richard Biener  changed:

   What|Removed |Added

   Keywords||wrong-code
   Priority|P3  |P1
 CC||law at gcc dot gnu.org

--- Comment #1 from Richard Biener  ---
From looking at svn log it must be caused by

r263591 | law | 2018-08-16 18:33:43 +0200 (Thu, 16 Aug 2018) | 8 lines

* expmed.h (canonicalize_comparison): New declaration.
* expmed.c (canonicalize_comparison, equivalent_cmp_code): New
function.
* expmed.c (emit_store_flag_1): Add call to canonicalize_comparison.
* optabs.c (prepare_cmp_insn): Likewise.
* rtl.h (unsigned_condition_p): New function which checks if a
comparison operator is unsigned.

* gcc.target/aarch64/imm_choice_comparison.c: New test.

Vlad doesn't seem to have a bugzilla account.

[Bug middle-end/86995] [9 regression] c-c++-common/torture/builtin-arith-overflow-17.c etc. FAIL

2018-08-17 Thread ro at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86995

Rainer Orth  changed:

   What|Removed |Added

   Target Milestone|--- |9.0