public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/15618] New: Missed bool optimization
@ 2004-05-24  1:29 pinskia at gcc dot gnu dot org
  2004-05-24  1:32 ` [Bug tree-optimization/15618] " pinskia at gcc dot gnu dot org
                   ` (10 more replies)
  0 siblings, 11 replies; 12+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-05-24  1:29 UTC (permalink / raw)
  To: gcc-bugs

The following three code should be produce the excatly the same asm:
int f(_Bool f1)
{
  if (f1 != 0)
   return 1;
  return 0;
}

int f3(_Bool f1)
{
  int f4;
  if (f1)
   f4 = 1;
  else
    f4 = 0;
  return f4;
}

int f5(_Bool f1)
{
  return f1;
}

-- 
           Summary: Missed bool optimization
           Product: gcc
           Version: 3.5.0
            Status: UNCONFIRMED
          Keywords: missed-optimization
          Severity: enhancement
          Priority: P2
         Component: tree-optimization
        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


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


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

* [Bug tree-optimization/15618] Missed bool optimization
  2004-05-24  1:29 [Bug tree-optimization/15618] New: Missed bool optimization pinskia at gcc dot gnu dot org
@ 2004-05-24  1:32 ` pinskia at gcc dot gnu dot org
  2004-05-27 17:01 ` pinskia at gcc dot gnu dot org
                   ` (9 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-05-24  1:32 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2004-05-23 17:22 -------
To fix the second one, you change if (Boolvalue != 0) to be just if (BoolValue)
To fix the first one you have to combine the return statement on the tree level.

-- 


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


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

* [Bug tree-optimization/15618] Missed bool optimization
  2004-05-24  1:29 [Bug tree-optimization/15618] New: Missed bool optimization pinskia at gcc dot gnu dot org
  2004-05-24  1:32 ` [Bug tree-optimization/15618] " pinskia at gcc dot gnu dot org
@ 2004-05-27 17:01 ` pinskia at gcc dot gnu dot org
  2004-06-07 18:05 ` pinskia at gcc dot gnu dot org
                   ` (8 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-05-27 17:01 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2004-05-26 23:34 -------
Here is the x86 asm:
f:
        xorl    %eax, %eax
        cmpb    $0, 4(%esp)
        setne   %al
        ret
        .size   f, .-f
        .p2align 4,,15
.globl f3
        .type   f3, @function
f3:
        xorl    %eax, %eax
        cmpb    $0, 4(%esp)
        setne   %al
        ret
        .size   f3, .-f3
        .p2align 4,,15
.globl f5
        .type   f5, @function
f5:
        movzbl  4(%esp), %eax
        ret
        .size   f5, .-f5

And PPC:
_f:
        addic r2,r3,-1
        subfe r4,r2,r3
        mr r3,r4
        blr
        .align 2
        .globl _f3
.section __TEXT,__text,regular,pure_instructions
        .align 2
_f3:
        addic r2,r3,-1
        subfe r4,r2,r3
        mr r3,r4
        blr
        .align 2
        .globl _f5
.section __TEXT,__text,regular,pure_instructions
        .align 2
_f5:
        blr

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|                            |1
   Last reconfirmed|0000-00-00 00:00:00         |2004-05-26 23:34:28
               date|                            |


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


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

* [Bug tree-optimization/15618] Missed bool optimization
  2004-05-24  1:29 [Bug tree-optimization/15618] New: Missed bool optimization pinskia at gcc dot gnu dot org
  2004-05-24  1:32 ` [Bug tree-optimization/15618] " pinskia at gcc dot gnu dot org
  2004-05-27 17:01 ` pinskia at gcc dot gnu dot org
@ 2004-06-07 18:05 ` pinskia at gcc dot gnu dot org
  2004-08-07 22:20 ` pinskia at gcc dot gnu dot org
                   ` (7 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-06-07 18:05 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2004-06-07 18:05 -------
The only thing left now is the conversion of Bool-value != 0 to Bool-value.

-- 


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


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

* [Bug tree-optimization/15618] Missed bool optimization
  2004-05-24  1:29 [Bug tree-optimization/15618] New: Missed bool optimization pinskia at gcc dot gnu dot org
                   ` (2 preceding siblings ...)
  2004-06-07 18:05 ` pinskia at gcc dot gnu dot org
@ 2004-08-07 22:20 ` pinskia at gcc dot gnu dot org
  2005-02-07 19:06 ` kazu at cs dot umass dot edu
                   ` (6 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-08-07 22:20 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2004-08-07 22:20 -------
*** Bug 15547 has been marked as a duplicate of this bug. ***

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |dann at godzilla dot ics dot
                   |                            |uci dot edu


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


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

* [Bug tree-optimization/15618] Missed bool optimization
  2004-05-24  1:29 [Bug tree-optimization/15618] New: Missed bool optimization pinskia at gcc dot gnu dot org
                   ` (3 preceding siblings ...)
  2004-08-07 22:20 ` pinskia at gcc dot gnu dot org
@ 2005-02-07 19:06 ` kazu at cs dot umass dot edu
  2005-05-01 17:29 ` pinskia at gcc dot gnu dot org
                   ` (5 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: kazu at cs dot umass dot edu @ 2005-02-07 19:06 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From kazu at cs dot umass dot edu  2005-02-07 05:40 -------
Here is the last tree SSA form:

;; Function f (f)

f (f1)
{
  _Bool D.1138;
  int D.1120;
  int D.1119;

<bb 0>:
  D.1138_5 = f1_2 != 0;
  D.1120_1 = (int) D.1138_5;
  return D.1120_1;

}

;; Function f3 (f3)

f3 (f1)
{
  _Bool D.1148;
  int f4;
  int D.1126;
  int D.1125;

<bb 0>:
  D.1148_4 = f1_2 != 0;
  f4_1 = (int) D.1148_4;
  return f4_1;

}

;; Function f5 (f5)

f5 (f1)
{
  int D.1130;

<bb 0>:
  D.1130_2 = (int) f1_1;
  return D.1130_2;

}


-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |kazu at cs dot umass dot edu


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


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

* [Bug tree-optimization/15618] Missed bool optimization
  2004-05-24  1:29 [Bug tree-optimization/15618] New: Missed bool optimization pinskia at gcc dot gnu dot org
                   ` (4 preceding siblings ...)
  2005-02-07 19:06 ` kazu at cs dot umass dot edu
@ 2005-05-01 17:29 ` pinskia at gcc dot gnu dot org
  2005-05-01 17:53 ` schlie at comcast dot net
                   ` (4 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-05-01 17:29 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2005-05-01 17:29 -------
I have a fix which I am testing.  One change to fold_binary to fold "bool_var != 0" to bool_var and one to 
fold_widened_comparison to treat BOOLEAN_TYPE like INTEGER_TYPE.

This improves the gimplification process for PR8361 so we get about 4 less statements.  And it lows the 
memory usage a little.

-- 
           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=15618


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

* [Bug tree-optimization/15618] Missed bool optimization
  2004-05-24  1:29 [Bug tree-optimization/15618] New: Missed bool optimization pinskia at gcc dot gnu dot org
                   ` (5 preceding siblings ...)
  2005-05-01 17:29 ` pinskia at gcc dot gnu dot org
@ 2005-05-01 17:53 ` schlie at comcast dot net
  2005-05-01 19:00 ` pinskia at gcc dot gnu dot org
                   ` (3 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: schlie at comcast dot net @ 2005-05-01 17:53 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From schlie at comcast dot net  2005-05-01 17:53 -------
(In reply to comment #6)
> I have a fix which I am testing.  One change to fold_binary to fold "bool_var != 0" to bool_var and
> one to  fold_widened_comparison to treat BOOLEAN_TYPE like INTEGER_TYPE.
> 
> This improves the gimplification process for PR8361 so we get about 4 less statements.  And it
> lows the memory usage a little.

As widening operations are a target specific optimization, should any such optimization be in
the target's code generator, where it may decide how to best treat bool types and/or operations?



-- 


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


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

* [Bug tree-optimization/15618] Missed bool optimization
  2004-05-24  1:29 [Bug tree-optimization/15618] New: Missed bool optimization pinskia at gcc dot gnu dot org
                   ` (6 preceding siblings ...)
  2005-05-01 17:53 ` schlie at comcast dot net
@ 2005-05-01 19:00 ` pinskia at gcc dot gnu dot org
  2005-05-03  1:16 ` pinskia at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-05-01 19:00 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2005-05-01 19:00 -------
Oh, this now longer will help the C++ front-end as we have "#define bool char".
I really hate that, we should not do it but we do :(.

-- 


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


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

* [Bug tree-optimization/15618] Missed bool optimization
  2004-05-24  1:29 [Bug tree-optimization/15618] New: Missed bool optimization pinskia at gcc dot gnu dot org
                   ` (7 preceding siblings ...)
  2005-05-01 19:00 ` pinskia at gcc dot gnu dot org
@ 2005-05-03  1:16 ` pinskia at gcc dot gnu dot org
  2005-05-04  1:52 ` cvs-commit at gcc dot gnu dot org
  2005-05-04  1:52 ` pinskia at gcc dot gnu dot org
  10 siblings, 0 replies; 12+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-05-03  1:16 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2005-05-03 01:16 -------
Patch here: <http://gcc.gnu.org/ml/gcc-patches/2005-05/msg00135.html>.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
                URL|                            |http://gcc.gnu.org/ml/gcc-
                   |                            |patches/2005-
                   |                            |05/msg00135.html
           Keywords|                            |patch


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


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

* [Bug tree-optimization/15618] Missed bool optimization
  2004-05-24  1:29 [Bug tree-optimization/15618] New: Missed bool optimization pinskia at gcc dot gnu dot org
                   ` (8 preceding siblings ...)
  2005-05-03  1:16 ` pinskia at gcc dot gnu dot org
@ 2005-05-04  1:52 ` cvs-commit at gcc dot gnu dot org
  2005-05-04  1:52 ` pinskia at gcc dot gnu dot org
  10 siblings, 0 replies; 12+ messages in thread
From: cvs-commit at gcc dot gnu dot org @ 2005-05-04  1:52 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From cvs-commit at gcc dot gnu dot org  2005-05-04 01:52 -------
Subject: Bug 15618

CVSROOT:	/cvs/gcc
Module name:	gcc
Changes by:	pinskia@gcc.gnu.org	2005-05-04 01:52:07

Modified files:
	gcc            : ChangeLog fold-const.c 
	gcc/testsuite  : ChangeLog 
Added files:
	gcc/testsuite/gcc.dg/tree-ssa: bool-1.c bool-2.c bool-3.c 
	                               bool-4.c bool-5.c bool-6.c 
	                               bool-7.c bool-8.c bool-9.c 

Log message:
	2004-05-03  Andrew Pinski  <pinskia@physics.uc.edu>
	
	PR middle-end/15618
	* fold-const.c (fold_widened_comparison): Treat BOOLEAN_TYPE
	the same as INTEGER_TYPE.
	(fold_binary): Fold "bool_var != 0" to bool_var.
	Fold "bool_var == 1" to bool_var.
	2005-05-03  Andrew Pinski  <pinskia@physics.uc.edu>
	
	PR middle-end/15618
	* gcc.dg/tree-ssa/bool-[1-9].c: New tests.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&r1=2.8592&r2=2.8593
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/fold-const.c.diff?cvsroot=gcc&r1=1.573&r2=1.574
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&r1=1.5438&r2=1.5439
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gcc.dg/tree-ssa/bool-1.c.diff?cvsroot=gcc&r1=NONE&r2=1.1
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gcc.dg/tree-ssa/bool-2.c.diff?cvsroot=gcc&r1=NONE&r2=1.1
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gcc.dg/tree-ssa/bool-3.c.diff?cvsroot=gcc&r1=NONE&r2=1.1
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gcc.dg/tree-ssa/bool-4.c.diff?cvsroot=gcc&r1=NONE&r2=1.1
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gcc.dg/tree-ssa/bool-5.c.diff?cvsroot=gcc&r1=NONE&r2=1.1
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gcc.dg/tree-ssa/bool-6.c.diff?cvsroot=gcc&r1=NONE&r2=1.1
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gcc.dg/tree-ssa/bool-7.c.diff?cvsroot=gcc&r1=NONE&r2=1.1
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gcc.dg/tree-ssa/bool-8.c.diff?cvsroot=gcc&r1=NONE&r2=1.1
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gcc.dg/tree-ssa/bool-9.c.diff?cvsroot=gcc&r1=NONE&r2=1.1



-- 


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


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

* [Bug tree-optimization/15618] Missed bool optimization
  2004-05-24  1:29 [Bug tree-optimization/15618] New: Missed bool optimization pinskia at gcc dot gnu dot org
                   ` (9 preceding siblings ...)
  2005-05-04  1:52 ` cvs-commit at gcc dot gnu dot org
@ 2005-05-04  1:52 ` pinskia at gcc dot gnu dot org
  10 siblings, 0 replies; 12+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-05-04  1:52 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2005-05-04 01:52 -------
Fixed.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|                            |FIXED
   Target Milestone|---                         |4.1.0


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


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

end of thread, other threads:[~2005-05-04  1:52 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-05-24  1:29 [Bug tree-optimization/15618] New: Missed bool optimization pinskia at gcc dot gnu dot org
2004-05-24  1:32 ` [Bug tree-optimization/15618] " pinskia at gcc dot gnu dot org
2004-05-27 17:01 ` pinskia at gcc dot gnu dot org
2004-06-07 18:05 ` pinskia at gcc dot gnu dot org
2004-08-07 22:20 ` pinskia at gcc dot gnu dot org
2005-02-07 19:06 ` kazu at cs dot umass dot edu
2005-05-01 17:29 ` pinskia at gcc dot gnu dot org
2005-05-01 17:53 ` schlie at comcast dot net
2005-05-01 19:00 ` pinskia at gcc dot gnu dot org
2005-05-03  1:16 ` pinskia at gcc dot gnu dot org
2005-05-04  1:52 ` cvs-commit at gcc dot gnu dot org
2005-05-04  1:52 ` pinskia 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).