public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug middle-end/23666] New: Fold does not reduce C - ~a into a + (C+1)
@ 2005-09-01  1:42 pinskia at gcc dot gnu dot org
  2005-09-01  6:20 ` [Bug middle-end/23666] " falk at debian dot org
                   ` (2 more replies)
  0 siblings, 3 replies; 11+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-09-01  1:42 UTC (permalink / raw)
  To: gcc-bugs

The asm for the following two functions should be the same.
int f(int a)
{
  return 10 - ~a;
}
int f1(int a)
{
  return a + 11;
}


Found while reading LLVM's instruction combiner.

-- 
           Summary: Fold does not reduce C - ~a into a + (C+1)
           Product: gcc
           Version: 4.1.0
            Status: UNCONFIRMED
          Keywords: missed-optimization
          Severity: enhancement
          Priority: P2
         Component: middle-end
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: pinskia at gcc dot gnu dot org
                CC: gcc-bugs at gcc dot gnu dot org
OtherBugsDependingO 19987
             nThis:


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23666


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug middle-end/23666] Fold does not reduce C - ~a into a + (C+1)
  2005-09-01  1:42 [Bug middle-end/23666] New: Fold does not reduce C - ~a into a + (C+1) pinskia at gcc dot gnu dot org
@ 2005-09-01  6:20 ` falk at debian dot org
  2005-09-01 12:00 ` pinskia at gcc dot gnu dot org
  2005-09-17  2:11 ` pinskia at gcc dot gnu dot org
  2 siblings, 0 replies; 11+ messages in thread
From: falk at debian dot org @ 2005-09-01  6:20 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From falk at debian dot org  2005-09-01 06:19 -------
Works for me on alphaev68-unknown-linux-gnu
 tiw with 4.1.0 20050819.

-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23666


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug middle-end/23666] Fold does not reduce C - ~a into a + (C+1)
  2005-09-01  1:42 [Bug middle-end/23666] New: Fold does not reduce C - ~a into a + (C+1) pinskia at gcc dot gnu dot org
  2005-09-01  6:20 ` [Bug middle-end/23666] " falk at debian dot org
@ 2005-09-01 12:00 ` pinskia at gcc dot gnu dot org
  2005-09-17  2:11 ` pinskia at gcc dot gnu dot org
  2 siblings, 0 replies; 11+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-09-01 12:00 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2005-09-01 11:59 -------
(In reply to comment #1)
> Works for me on alphaev68-unknown-linux-gnu
>  tiw with 4.1.0 20050819.

And does not with 4.1.0 20050901 on i686-pc-linux-gnu or on powerpc-darwin.

-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23666


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug middle-end/23666] Fold does not reduce C - ~a into a + (C+1)
  2005-09-01  1:42 [Bug middle-end/23666] New: Fold does not reduce C - ~a into a + (C+1) pinskia at gcc dot gnu dot org
  2005-09-01  6:20 ` [Bug middle-end/23666] " falk at debian dot org
  2005-09-01 12:00 ` pinskia at gcc dot gnu dot org
@ 2005-09-17  2:11 ` pinskia at gcc dot gnu dot org
  2 siblings, 0 replies; 11+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-09-17  2:11 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2005-09-17 02:11 -------
Confirmed.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|                            |1
   Last reconfirmed|0000-00-00 00:00:00         |2005-09-17 02:11:51
               date|                            |


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23666


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug middle-end/23666] Fold does not reduce C - ~a into a + (C+1)
       [not found] <bug-23666-6528@http.gcc.gnu.org/bugzilla/>
                   ` (5 preceding siblings ...)
  2005-11-30 16:48 ` pinskia at gcc dot gnu dot org
@ 2006-10-22 15:12 ` rguenth at gcc dot gnu dot org
  6 siblings, 0 replies; 11+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2006-10-22 15:12 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #10 from rguenth at gcc dot gnu dot org  2006-10-22 15:12 -------
With the patch for 23295 we get the behavior as noted in comment #7.  This is
due
to negate_expr_p (correctly) containing

    case BIT_NOT_EXPR:
       return INTEGRAL_TYPE_P (type)
              && (TYPE_UNSIGNED (type)
                  || (flag_wrapv && !flag_trapv));

as negating ~7ffffff will result in signed overflow which is undefined without
flag_wrapv.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23666


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug middle-end/23666] Fold does not reduce C - ~a into a + (C+1)
       [not found] <bug-23666-6528@http.gcc.gnu.org/bugzilla/>
                   ` (4 preceding siblings ...)
  2005-11-29  0:39 ` pinskia at gcc dot gnu dot org
@ 2005-11-30 16:48 ` pinskia at gcc dot gnu dot org
  2006-10-22 15:12 ` rguenth at gcc dot gnu dot org
  6 siblings, 0 replies; 11+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-11-30 16:48 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #9 from pinskia at gcc dot gnu dot org  2005-11-30 16:48 -------
This is exactly the same issue as PR 23295 now (I should copy some of the
comments from here to there).


-- 

pinskia at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
  BugsThisDependsOn|                            |23295


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23666


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug middle-end/23666] Fold does not reduce C - ~a into a + (C+1)
       [not found] <bug-23666-6528@http.gcc.gnu.org/bugzilla/>
                   ` (3 preceding siblings ...)
  2005-11-27 22:26 ` pinskia at gcc dot gnu dot org
@ 2005-11-29  0:39 ` pinskia at gcc dot gnu dot org
  2005-11-30 16:48 ` pinskia at gcc dot gnu dot org
  2006-10-22 15:12 ` rguenth at gcc dot gnu dot org
  6 siblings, 0 replies; 11+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-11-29  0:39 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #8 from pinskia at gcc dot gnu dot org  2005-11-29 00:39 -------
I am not going to fix this now as it exposes too many VRP issues and other
issues.


-- 

pinskia at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         AssignedTo|pinskia at gcc dot gnu dot  |unassigned at gcc dot gnu
                   |org                         |dot org
             Status|ASSIGNED                    |NEW


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23666


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug middle-end/23666] Fold does not reduce C - ~a into a + (C+1)
       [not found] <bug-23666-6528@http.gcc.gnu.org/bugzilla/>
                   ` (2 preceding siblings ...)
  2005-11-26 22:53 ` pinskia at gcc dot gnu dot org
@ 2005-11-27 22:26 ` pinskia at gcc dot gnu dot org
  2005-11-29  0:39 ` pinskia at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 11+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-11-27 22:26 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #7 from pinskia at gcc dot gnu dot org  2005-11-27 22:26 -------
After the patch which I am about to test, we get this with -fwrapv (yes that is
weird we get it with something which should be cause optimizations not to
happen and not the other way around).


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23666


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug middle-end/23666] Fold does not reduce C - ~a into a + (C+1)
       [not found] <bug-23666-6528@http.gcc.gnu.org/bugzilla/>
  2005-11-26 21:43 ` pinskia at gcc dot gnu dot org
  2005-11-26 22:38 ` pinskia at gcc dot gnu dot org
@ 2005-11-26 22:53 ` pinskia at gcc dot gnu dot org
  2005-11-27 22:26 ` pinskia at gcc dot gnu dot org
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 11+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-11-26 22:53 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #6 from pinskia at gcc dot gnu dot org  2005-11-26 22:53 -------
Actually it is just a check for flag_wrapv which looks to be wrong as far as I
can tell.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23666


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug middle-end/23666] Fold does not reduce C - ~a into a + (C+1)
       [not found] <bug-23666-6528@http.gcc.gnu.org/bugzilla/>
  2005-11-26 21:43 ` pinskia at gcc dot gnu dot org
@ 2005-11-26 22:38 ` pinskia at gcc dot gnu dot org
  2005-11-26 22:53 ` pinskia at gcc dot gnu dot org
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 11+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-11-26 22:38 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #5 from pinskia at gcc dot gnu dot org  2005-11-26 22:38 -------
Actually there is two things that need to be done, first is what I said in
comment # 4 and then the second thing is for MINUS_EXPR to use those functions
instead of checking explicatly for NEGATE_EXPR.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23666


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug middle-end/23666] Fold does not reduce C - ~a into a + (C+1)
       [not found] <bug-23666-6528@http.gcc.gnu.org/bugzilla/>
@ 2005-11-26 21:43 ` pinskia at gcc dot gnu dot org
  2005-11-26 22:38 ` pinskia at gcc dot gnu dot org
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 11+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-11-26 21:43 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from pinskia at gcc dot gnu dot org  2005-11-26 21:43 -------
The problem here is my fault, slightly.  Fold is converting -(~a) in the
NEGATE_EXPR but not in the generic functions to do the negation.  I will do the
patch for this one.  (I am saying that -(~a) is more complex than a+1 which is
true).


-- 

pinskia at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         AssignedTo|unassigned at gcc dot gnu   |pinskia at gcc dot gnu dot
                   |dot org                     |org
             Status|NEW                         |ASSIGNED


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23666


^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2006-10-22 15:12 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-09-01  1:42 [Bug middle-end/23666] New: Fold does not reduce C - ~a into a + (C+1) pinskia at gcc dot gnu dot org
2005-09-01  6:20 ` [Bug middle-end/23666] " falk at debian dot org
2005-09-01 12:00 ` pinskia at gcc dot gnu dot org
2005-09-17  2:11 ` pinskia at gcc dot gnu dot org
     [not found] <bug-23666-6528@http.gcc.gnu.org/bugzilla/>
2005-11-26 21:43 ` pinskia at gcc dot gnu dot org
2005-11-26 22:38 ` pinskia at gcc dot gnu dot org
2005-11-26 22:53 ` pinskia at gcc dot gnu dot org
2005-11-27 22:26 ` pinskia at gcc dot gnu dot org
2005-11-29  0:39 ` pinskia at gcc dot gnu dot org
2005-11-30 16:48 ` pinskia at gcc dot gnu dot org
2006-10-22 15:12 ` rguenth at gcc dot gnu dot org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).