This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug middle-end/58564] [4.7/4.8/4.9 Regression] possible wrong code bug at -O0
- From: "jakub at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Mon, 30 Sep 2013 08:43:46 +0000
- Subject: [Bug middle-end/58564] [4.7/4.8/4.9 Regression] possible wrong code bug at -O0
- Auto-submitted: auto-generated
- References: <bug-58564-4 at http dot gcc dot gnu dot org/bugzilla/>
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58564
Jakub Jelinek <jakub at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |jakub at gcc dot gnu.org
Component|c |middle-end
Target Milestone|--- |4.7.4
Summary|possible wrong code bug at |[4.7/4.8/4.9 Regression]
|-O0 |possible wrong code bug at
| |-O0
--- Comment #6 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
I think the bug is in the
/* A < 0 ? <sign bit of A> : 0 is simply (A & <sign bit of A>). */
if (TREE_CODE (arg0) == LT_EXPR
&& integer_zerop (TREE_OPERAND (arg0, 1))
&& integer_zerop (op2)
&& (tem = sign_bit_p (TREE_OPERAND (arg0, 0), arg1)))
...
transformation in fold_ternary_loc or sign_bit_p or combination thereof.
We get here with arg0 ((int) (d == &c && a != 1)) < 0, arg1 1U and arg2 0U,
sign_bit_p (surprisingly) looks through zero extensions (of bool to int)
and returns (d == &c && a != 1) and we incorrectly fold it as
(d == &c && a != 1) & 1.