public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug middle-end/28685] Multiple comparisons are not simplified
       [not found] <bug-28685-4@http.gcc.gnu.org/bugzilla/>
@ 2012-01-12  1:07 ` pinskia at gcc dot gnu.org
  2012-02-05 12:42 ` ubizjak at gmail dot com
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 23+ messages in thread
From: pinskia at gcc dot gnu.org @ 2012-01-12  1:07 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Last reconfirmed|2008-04-30 15:12:57         |2012-01-11

--- Comment #17 from Andrew Pinski <pinskia at gcc dot gnu.org> 2012-01-12 01:06:09 UTC ---
The only one which is not fixed is comment #4


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

* [Bug middle-end/28685] Multiple comparisons are not simplified
       [not found] <bug-28685-4@http.gcc.gnu.org/bugzilla/>
  2012-01-12  1:07 ` [Bug middle-end/28685] Multiple comparisons are not simplified pinskia at gcc dot gnu.org
@ 2012-02-05 12:42 ` ubizjak at gmail dot com
  2012-02-06 21:37 ` ubizjak at gmail dot com
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 23+ messages in thread
From: ubizjak at gmail dot com @ 2012-02-05 12:42 UTC (permalink / raw)
  To: gcc-bugs

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

Uros Bizjak <ubizjak at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |ASSIGNED
   Target Milestone|---                         |4.8.0

--- Comment #18 from Uros Bizjak <ubizjak at gmail dot com> 2012-02-05 12:40:17 UTC ---
(In reply to comment #17)
> The only one which is not fixed is comment #4

Following patch that enables post-reload compare elimination:

--cut here--
Index: config/i386/i386.c
===================================================================
--- config/i386/i386.c  (revision 183904)
+++ config/i386/i386.c  (working copy)
@@ -38685,6 +38685,9 @@
 #undef TARGET_EXPAND_TO_RTL_HOOK
 #define TARGET_EXPAND_TO_RTL_HOOK ix86_maybe_switch_abi

+#undef TARGET_FLAGS_REGNUM
+#define TARGET_FLAGS_REGNUM FLAGS_REG
+
 #undef TARGET_LEGITIMATE_ADDRESS_P
 #define TARGET_LEGITIMATE_ADDRESS_P ix86_legitimate_address_p

--cut here--

generates (-O2):

test:
        xorl    %edx, %edx
        cmpl    %esi, %edi
        movl    $1, %eax
        sete    %dl
        cmovge  %edx, %eax
        ret

Please note missing comparison.

This shows that the pass is effective for x86_64, but will be enabled for 4.8.


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

* [Bug middle-end/28685] Multiple comparisons are not simplified
       [not found] <bug-28685-4@http.gcc.gnu.org/bugzilla/>
  2012-01-12  1:07 ` [Bug middle-end/28685] Multiple comparisons are not simplified pinskia at gcc dot gnu.org
  2012-02-05 12:42 ` ubizjak at gmail dot com
@ 2012-02-06 21:37 ` ubizjak at gmail dot com
  2012-04-22 12:42 ` ubizjak at gmail dot com
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 23+ messages in thread
From: ubizjak at gmail dot com @ 2012-02-06 21:37 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #19 from Uros Bizjak <ubizjak at gmail dot com> 2012-02-06 21:36:01 UTC ---
(In reply to comment #4)
> Another similar, but yet different case:

Yet another similar test:

int test (int a, int b)
{
  int lt = a + b < 0;
  int eq = a + b == 0;
  if (lt)
    return 1;
  return eq;
}

combine pass creates:

            (set (reg:CCZ 17 flags)
                (compare:CCZ (plus:SI (reg/v:SI 63 [ a ])
                        (reg/v:SI 64 [ b ]))
                    (const_int 0 [0])))
            (set (reg:SI 60 [ D.1710 ])
                (plus:SI (reg/v:SI 63 [ a ])
                    (reg/v:SI 64 [ b ])))

we have a discrepancy here, since compare elimination pass expects RTX in the
form of:

 [(operate)
  (set-cc)]


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

* [Bug middle-end/28685] Multiple comparisons are not simplified
       [not found] <bug-28685-4@http.gcc.gnu.org/bugzilla/>
                   ` (2 preceding siblings ...)
  2012-02-06 21:37 ` ubizjak at gmail dot com
@ 2012-04-22 12:42 ` ubizjak at gmail dot com
  2012-04-22 12:46 ` ubizjak at gmail dot com
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 23+ messages in thread
From: ubizjak at gmail dot com @ 2012-04-22 12:42 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #20 from Uros Bizjak <ubizjak at gmail dot com> 2012-04-22 12:42:07 UTC ---
(In reply to comment #19)

> int test (int a, int b)
> {
>   int lt = a + b < 0;
>   int eq = a + b == 0;
>   if (lt)
>     return 1;
>   return eq;
> }

Actually, here ce1 pass steps on cse2 pass. ce1 pass flattens jump-over with a
conditional set. cse2 pass doesn't CSE jumpless blocks (see
cse_condition_code_reg), claiming that:

      /* Look for blocks which end with a conditional jump based on a
     condition code register.  Then look for the instruction which
     sets the condition code register.  Then look through the
     successor blocks for instructions which set the condition
     code register to the same value.  There are other possible
     uses of the condition code register, but these are by far the
     most common and the ones which we are most likely to be able
     to optimize.  */

Changing the source to:

int test (int a, int b)
{
  int lt = a + b < 0;
  int eq = a + b == 0;
  if (lt)
    return 15;
  return eq;
}

yields one compare (the one in add insn):

test:
        addl    %esi, %edi
        movl    $15, %eax
        js      .L2
        sete    %al
        movzbl  %al, %eax
.L2:
        rep
        ret


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

* [Bug middle-end/28685] Multiple comparisons are not simplified
       [not found] <bug-28685-4@http.gcc.gnu.org/bugzilla/>
                   ` (3 preceding siblings ...)
  2012-04-22 12:42 ` ubizjak at gmail dot com
@ 2012-04-22 12:46 ` ubizjak at gmail dot com
  2012-04-22 12:48 ` ubizjak at gmail dot com
  2014-10-31  4:02 ` pinskia at gcc dot gnu.org
  6 siblings, 0 replies; 23+ messages in thread
From: ubizjak at gmail dot com @ 2012-04-22 12:46 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #21 from Uros Bizjak <ubizjak at gmail dot com> 2012-04-22 12:45:17 UTC ---
(In reply to comment #17)
> The only one which is not fixed is comment #4

This testcase is fixed with patch at [1].

[1] http://gcc.gnu.org/ml/gcc-patches/2012-02/msg00295.html


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

* [Bug middle-end/28685] Multiple comparisons are not simplified
       [not found] <bug-28685-4@http.gcc.gnu.org/bugzilla/>
                   ` (4 preceding siblings ...)
  2012-04-22 12:46 ` ubizjak at gmail dot com
@ 2012-04-22 12:48 ` ubizjak at gmail dot com
  2014-10-31  4:02 ` pinskia at gcc dot gnu.org
  6 siblings, 0 replies; 23+ messages in thread
From: ubizjak at gmail dot com @ 2012-04-22 12:48 UTC (permalink / raw)
  To: gcc-bugs

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

Uros Bizjak <ubizjak at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|                            |FIXED

--- Comment #22 from Uros Bizjak <ubizjak at gmail dot com> 2012-04-22 12:48:21 UTC ---
(In reply to comment #18)

> Following patch that enables post-reload compare elimination:
>
> ...
>
> This shows that the pass is effective for x86_64, but will be enabled for 4.8.

Not worth for x86. All interesting cases were fixed by other patches.

So, fixed.


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

* [Bug middle-end/28685] Multiple comparisons are not simplified
       [not found] <bug-28685-4@http.gcc.gnu.org/bugzilla/>
                   ` (5 preceding siblings ...)
  2012-04-22 12:48 ` ubizjak at gmail dot com
@ 2014-10-31  4:02 ` pinskia at gcc dot gnu.org
  6 siblings, 0 replies; 23+ messages in thread
From: pinskia at gcc dot gnu.org @ 2014-10-31  4:02 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=28685
Bug 28685 depends on bug 15459, which changed state.

Bug 15459 Summary: [meta-bug] there should be a tree combiner like the rtl one
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=15459

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|---                         |FIXED


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

* [Bug middle-end/28685] Multiple comparisons are not simplified
  2006-08-10 18:15 [Bug middle-end/28685] New: " uros at kss-loka dot si
                   ` (14 preceding siblings ...)
  2010-06-01  2:24 ` sandra at codesourcery dot com
@ 2010-06-08 18:16 ` sandra at gcc dot gnu dot org
  15 siblings, 0 replies; 23+ messages in thread
From: sandra at gcc dot gnu dot org @ 2010-06-08 18:16 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #16 from sandra at gcc dot gnu dot org  2010-06-08 18:16 -------
Subject: Bug 28685

Author: sandra
Date: Tue Jun  8 18:15:53 2010
New Revision: 160445

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=160445
Log:
2010-06-08  Sandra Loosemore  <sandra@codesourcery.com>

        PR tree-optimization/39874
        PR middle-end/28685

        gcc/
        * gimple.h (maybe_fold_and_comparisons, maybe_fold_or_comparisons):
        Declare.
        * gimple-fold.c (canonicalize_bool, same_bool_comparison_p,
        same_bool_result_p): New.
        (and_var_with_comparison, and_var_with_comparison_1,
        and_comparisons_1, and_comparisons, maybe_fold_and_comparisons): New.
        (or_var_with_comparison, or_var_with_comparison_1,
        or_comparisons_1, or_comparisons, maybe_fold_or_comparisons): New.
        * tree-ssa-reassoc.c (eliminate_redundant_comparison): Use
        maybe_fold_and_comparisons or maybe_fold_or_comparisons instead
        of combine_comparisons.
        * tree-ssa-ifcombine.c (ifcombine_ifandif, ifcombine_iforif): Likewise.

        gcc/testsuite/
        * gcc.dg/pr39874.c: New file.

Added:
    trunk/gcc/testsuite/gcc.dg/pr39874.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/gimple-fold.c
    trunk/gcc/gimple.h
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/tree-ssa-ifcombine.c
    trunk/gcc/tree-ssa-reassoc.c


-- 


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


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

* [Bug middle-end/28685] Multiple comparisons are not simplified
  2006-08-10 18:15 [Bug middle-end/28685] New: " uros at kss-loka dot si
                   ` (13 preceding siblings ...)
  2010-05-25  8:12 ` rguenther at suse dot de
@ 2010-06-01  2:24 ` sandra at codesourcery dot com
  2010-06-08 18:16 ` sandra at gcc dot gnu dot org
  15 siblings, 0 replies; 23+ messages in thread
From: sandra at codesourcery dot com @ 2010-06-01  2:24 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #15 from sandra at codesourcery dot com  2010-06-01 02:24 -------
Proposed patch for PR 39874/comment #5 posted here:

http://gcc.gnu.org/ml/gcc-patches/2010-06/msg00001.html


-- 


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


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

* [Bug middle-end/28685] Multiple comparisons are not simplified
  2006-08-10 18:15 [Bug middle-end/28685] New: " uros at kss-loka dot si
                   ` (12 preceding siblings ...)
  2010-05-24 13:22 ` sandra at codesourcery dot com
@ 2010-05-25  8:12 ` rguenther at suse dot de
  2010-06-01  2:24 ` sandra at codesourcery dot com
  2010-06-08 18:16 ` sandra at gcc dot gnu dot org
  15 siblings, 0 replies; 23+ messages in thread
From: rguenther at suse dot de @ 2010-05-25  8:12 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #14 from rguenther at suse dot de  2010-05-25 08:11 -------
Subject: Re:  Multiple comparisons are not simplified

On Mon, 24 May 2010, sandra at codesourcery dot com wrote:

> ------- Comment #13 from sandra at codesourcery dot com  2010-05-24 13:21 -------
> I'm working on a patch that fixes the test case in comment #5 (originally filed
> as PR 39874) and some other test cases by improving the comparison combination
> logic in both tree-ssa-ifcombine and tree-ssa-reassoc.
> 
> The test case in comment #4 is a somewhat different problem -- maybe it is a
> VRP failure?  The problem is figuring out the right place to attempt to combine
> the comparisons....

In this case it is probably phiopt that could recognize this (though
it does not do the kind of transformation).  It could transform

<bb 2>:
  eq_5 = a_2(D) == b_3(D);
  if (a_2(D) < b_3(D))
    goto <bb 4>;
  else
    goto <bb 3>;

<bb 3>:

<bb 4>:
  # eq_1 = PHI <1(2), eq_5(3)>
  return eq_1;

to

<bb 2>:
  if (a_2(D) <= b_3(D))
    goto <bb 4>;
  else
    goto <bb 3>;

<bb 3>:

<bb 4>:
  # eq_1 = PHI <1(2), 0(3)>
  return eq_1;

and eventually further if-convert that.

Richard.


-- 


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


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

* [Bug middle-end/28685] Multiple comparisons are not simplified
  2006-08-10 18:15 [Bug middle-end/28685] New: " uros at kss-loka dot si
                   ` (11 preceding siblings ...)
  2010-05-08 15:54 ` sandra at gcc dot gnu dot org
@ 2010-05-24 13:22 ` sandra at codesourcery dot com
  2010-05-25  8:12 ` rguenther at suse dot de
                   ` (2 subsequent siblings)
  15 siblings, 0 replies; 23+ messages in thread
From: sandra at codesourcery dot com @ 2010-05-24 13:22 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #13 from sandra at codesourcery dot com  2010-05-24 13:21 -------
I'm working on a patch that fixes the test case in comment #5 (originally filed
as PR 39874) and some other test cases by improving the comparison combination
logic in both tree-ssa-ifcombine and tree-ssa-reassoc.

The test case in comment #4 is a somewhat different problem -- maybe it is a
VRP failure?  The problem is figuring out the right place to attempt to combine
the comparisons....


-- 


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


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

* [Bug middle-end/28685] Multiple comparisons are not simplified
  2006-08-10 18:15 [Bug middle-end/28685] New: " uros at kss-loka dot si
                   ` (10 preceding siblings ...)
  2010-05-08  3:44 ` sandra at codesourcery dot com
@ 2010-05-08 15:54 ` sandra at gcc dot gnu dot org
  2010-05-24 13:22 ` sandra at codesourcery dot com
                   ` (3 subsequent siblings)
  15 siblings, 0 replies; 23+ messages in thread
From: sandra at gcc dot gnu dot org @ 2010-05-08 15:54 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #12 from sandra at gcc dot gnu dot org  2010-05-08 15:54 -------
Subject: Bug 28685

Author: sandra
Date: Sat May  8 15:53:59 2010
New Revision: 159189

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=159189
Log:
2010-05-08  Sandra Loosemore  <sandra@codesourcery.com>

        PR middle-end/28685

        gcc/
        * tree-ssa-reassoc.c (eliminate_redundant_comparison): New function.
        (optimize_ops_list): Call it.

        gcc/testsuite/
        * gcc.dg/pr28685-1.c: New file.

Added:
    trunk/gcc/testsuite/gcc.dg/pr28685-1.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/tree-ssa-reassoc.c


-- 


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


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

* [Bug middle-end/28685] Multiple comparisons are not simplified
  2006-08-10 18:15 [Bug middle-end/28685] New: " uros at kss-loka dot si
                   ` (9 preceding siblings ...)
  2010-05-07  2:32 ` sandra at codesourcery dot com
@ 2010-05-08  3:44 ` sandra at codesourcery dot com
  2010-05-08 15:54 ` sandra at gcc dot gnu dot org
                   ` (4 subsequent siblings)
  15 siblings, 0 replies; 23+ messages in thread
From: sandra at codesourcery dot com @ 2010-05-08  3:44 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #11 from sandra at codesourcery dot com  2010-05-08 03:43 -------
I've posted the patch to fix the first testcase here:

http://gcc.gnu.org/ml/gcc-patches/2010-05/msg00564.html


-- 


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


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

* [Bug middle-end/28685] Multiple comparisons are not simplified
  2006-08-10 18:15 [Bug middle-end/28685] New: " uros at kss-loka dot si
                   ` (8 preceding siblings ...)
  2009-09-17 10:25 ` ubizjak at gmail dot com
@ 2010-05-07  2:32 ` sandra at codesourcery dot com
  2010-05-08  3:44 ` sandra at codesourcery dot com
                   ` (5 subsequent siblings)
  15 siblings, 0 replies; 23+ messages in thread
From: sandra at codesourcery dot com @ 2010-05-07  2:32 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #10 from sandra at codesourcery dot com  2010-05-07 02:32 -------
I've been working on a patch that fixes the original reported problem by adding
a little logic to tree-ssa-reassoc.c to make it look for places where it can
use combine_comparisons.  Note that this test case does not involve an "if" or
require any particular CFA, just straightforward expression simplification.  My
sense is that the test cases that do involve "if"s and/or require flow analysis
are in fact different bugs that require different fixes.  (In fact, 28691 looks
more like an RTL-level optimization to me, maybe even backend-specific.)  So,
is it really useful to lump them all together as duplicates for tracking
purposes?  Or am I totally barking up the wrong tree here?    


-- 

sandra at codesourcery dot com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |sandra at codesourcery dot
                   |                            |com


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


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

* [Bug middle-end/28685] Multiple comparisons are not simplified
  2006-08-10 18:15 [Bug middle-end/28685] New: " uros at kss-loka dot si
                   ` (7 preceding siblings ...)
  2009-06-24  9:15 ` rguenth at gcc dot gnu dot org
@ 2009-09-17 10:25 ` ubizjak at gmail dot com
  2010-05-07  2:32 ` sandra at codesourcery dot com
                   ` (6 subsequent siblings)
  15 siblings, 0 replies; 23+ messages in thread
From: ubizjak at gmail dot com @ 2009-09-17 10:25 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #9 from ubizjak at gmail dot com  2009-09-17 10:25 -------
*** Bug 28691 has been marked as a duplicate of this bug. ***


-- 

ubizjak at gmail dot com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |tbptbp at gmail dot com


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


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

* [Bug middle-end/28685] Multiple comparisons are not simplified
  2006-08-10 18:15 [Bug middle-end/28685] New: " uros at kss-loka dot si
                   ` (6 preceding siblings ...)
  2009-06-24  7:49 ` steven at gcc dot gnu dot org
@ 2009-06-24  9:15 ` rguenth at gcc dot gnu dot org
  2009-09-17 10:25 ` ubizjak at gmail dot com
                   ` (7 subsequent siblings)
  15 siblings, 0 replies; 23+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2009-06-24  9:15 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #8 from rguenth at gcc dot gnu dot org  2009-06-24 09:15 -------
:P

I am currently not working on a fix for this (heh, people may have noticed
that ...).  My idea was to build an on-the-side CFG for this and use that
in tree-ssa-ifcombine.c - I just never came around implementing that.


-- 

rguenth at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |rguenth at gcc dot gnu dot
                   |                            |org
         AssignedTo|rguenth 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=28685


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

* [Bug middle-end/28685] Multiple comparisons are not simplified
  2006-08-10 18:15 [Bug middle-end/28685] New: " uros at kss-loka dot si
                   ` (5 preceding siblings ...)
  2009-04-24  9:25 ` rguenth at gcc dot gnu dot org
@ 2009-06-24  7:49 ` steven at gcc dot gnu dot org
  2009-06-24  9:15 ` rguenth at gcc dot gnu dot org
                   ` (8 subsequent siblings)
  15 siblings, 0 replies; 23+ messages in thread
From: steven at gcc dot gnu dot org @ 2009-06-24  7:49 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #7 from steven at gcc dot gnu dot org  2009-06-24 07:49 -------
How are things progressing with a fix for this, Richi? :-)


-- 


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


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

* [Bug middle-end/28685] Multiple comparisons are not simplified
  2006-08-10 18:15 [Bug middle-end/28685] New: " uros at kss-loka dot si
                   ` (4 preceding siblings ...)
  2009-04-24  9:24 ` rguenth at gcc dot gnu dot org
@ 2009-04-24  9:25 ` rguenth at gcc dot gnu dot org
  2009-06-24  7:49 ` steven at gcc dot gnu dot org
                   ` (9 subsequent siblings)
  15 siblings, 0 replies; 23+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2009-04-24  9:25 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #6 from rguenth at gcc dot gnu dot org  2009-04-24 09:24 -------
*** Bug 39874 has been marked as a duplicate of this bug. ***


-- 

rguenth at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |alexvod at google dot com


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


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

* [Bug middle-end/28685] Multiple comparisons are not simplified
  2006-08-10 18:15 [Bug middle-end/28685] New: " uros at kss-loka dot si
                   ` (3 preceding siblings ...)
  2008-10-12 20:46 ` rguenth at gcc dot gnu dot org
@ 2009-04-24  9:24 ` rguenth at gcc dot gnu dot org
  2009-04-24  9:25 ` rguenth at gcc dot gnu dot org
                   ` (10 subsequent siblings)
  15 siblings, 0 replies; 23+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2009-04-24  9:24 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #5 from rguenth at gcc dot gnu dot org  2009-04-24 09:24 -------
Another case:

void func();
void test(char *signature)
{
  char ch = signature[0];
  if (ch == 15 || ch == 3)
  {
    if (ch == 15) func();
  }
}


-- 


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


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

* [Bug middle-end/28685] Multiple comparisons are not simplified
  2006-08-10 18:15 [Bug middle-end/28685] New: " uros at kss-loka dot si
                   ` (2 preceding siblings ...)
  2008-09-06 16:34 ` ubizjak at gmail dot com
@ 2008-10-12 20:46 ` rguenth at gcc dot gnu dot org
  2009-04-24  9:24 ` rguenth at gcc dot gnu dot org
                   ` (11 subsequent siblings)
  15 siblings, 0 replies; 23+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2008-10-12 20:46 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from rguenth at gcc dot gnu dot org  2008-10-12 20:45 -------
Another similar, but yet different case:

int test(int a, int b)
{
  int lt = a < b;
  int eq = a == b;
  if (lt)
    return 1;
  return eq;
}

this is what we "optimize" it to:

test (int a, int b)
{
  int eq;

<bb 2>:
  eq_5 = a_2(D) == b_3(D);
  if (a_2(D) < b_3(D))
    goto <bb 4>;
  else
    goto <bb 3>;

<bb 3>:

<bb 4>:
  # eq_1 = PHI <1(2), eq_5(3)>
  return eq_1;


test:
        pushl   %ebp
        movl    $1, %eax
        movl    %esp, %ebp
        movl    12(%ebp), %edx
        cmpl    %edx, 8(%ebp)
        jl      .L3
        sete    %al
        movzbl  %al, %eax
.L3:
        popl    %ebp
        ret


-- 


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


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

* [Bug middle-end/28685] Multiple comparisons are not simplified
  2006-08-10 18:15 [Bug middle-end/28685] New: " uros at kss-loka dot si
  2006-08-10 18:18 ` [Bug middle-end/28685] " pinskia at gcc dot gnu dot org
  2008-04-30 15:13 ` rguenth at gcc dot gnu dot org
@ 2008-09-06 16:34 ` ubizjak at gmail dot com
  2008-10-12 20:46 ` rguenth at gcc dot gnu dot org
                   ` (12 subsequent siblings)
  15 siblings, 0 replies; 23+ messages in thread
From: ubizjak at gmail dot com @ 2008-09-06 16:34 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from ubizjak at gmail dot com  2008-09-06 16:33 -------
gcc (4.4.0 20080906) still generates:

        cmpl    %esi, %edi
        sete    %al
        cmpl    %esi, %edi
        setl    %dl
        orl     %edx, %eax
        movzbl  %al, %eax
        ret


-- 


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


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

* [Bug middle-end/28685] Multiple comparisons are not simplified
  2006-08-10 18:15 [Bug middle-end/28685] New: " uros at kss-loka dot si
  2006-08-10 18:18 ` [Bug middle-end/28685] " pinskia at gcc dot gnu dot org
@ 2008-04-30 15:13 ` rguenth at gcc dot gnu dot org
  2008-09-06 16:34 ` ubizjak at gmail dot com
                   ` (13 subsequent siblings)
  15 siblings, 0 replies; 23+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2008-04-30 15:13 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from rguenth at gcc dot gnu dot org  2008-04-30 15:12 -------
A third variant is optimized by the ifcombine pass:

int test__(int a, int b)
{
  if (a < b)
    return 1;
  if (a == b)
    return 1;
  return 0;
}

in principle ifcombine could handle flow-less combining as well.  I'll put
that on my TODO.


-- 

rguenth at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         AssignedTo|unassigned at gcc dot gnu   |rguenth at gcc dot gnu dot
                   |dot org                     |org
             Status|NEW                         |ASSIGNED
   Last reconfirmed|2006-08-10 18:18:10         |2008-04-30 15:12:57
               date|                            |


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


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

* [Bug middle-end/28685] Multiple comparisons are not simplified
  2006-08-10 18:15 [Bug middle-end/28685] New: " uros at kss-loka dot si
@ 2006-08-10 18:18 ` pinskia at gcc dot gnu dot org
  2008-04-30 15:13 ` rguenth at gcc dot gnu dot org
                   ` (14 subsequent siblings)
  15 siblings, 0 replies; 23+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2006-08-10 18:18 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from pinskia at gcc dot gnu dot org  2006-08-10 18:18 -------
This all comes down to a tree combiner.


-- 

pinskia at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
  BugsThisDependsOn|                            |15459
           Severity|normal                      |enhancement
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|0                           |1
           Keywords|                            |missed-optimization
   Last reconfirmed|0000-00-00 00:00:00         |2006-08-10 18:18:10
               date|                            |


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


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

end of thread, other threads:[~2014-10-31  4:02 UTC | newest]

Thread overview: 23+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <bug-28685-4@http.gcc.gnu.org/bugzilla/>
2012-01-12  1:07 ` [Bug middle-end/28685] Multiple comparisons are not simplified pinskia at gcc dot gnu.org
2012-02-05 12:42 ` ubizjak at gmail dot com
2012-02-06 21:37 ` ubizjak at gmail dot com
2012-04-22 12:42 ` ubizjak at gmail dot com
2012-04-22 12:46 ` ubizjak at gmail dot com
2012-04-22 12:48 ` ubizjak at gmail dot com
2014-10-31  4:02 ` pinskia at gcc dot gnu.org
2006-08-10 18:15 [Bug middle-end/28685] New: " uros at kss-loka dot si
2006-08-10 18:18 ` [Bug middle-end/28685] " pinskia at gcc dot gnu dot org
2008-04-30 15:13 ` rguenth at gcc dot gnu dot org
2008-09-06 16:34 ` ubizjak at gmail dot com
2008-10-12 20:46 ` rguenth at gcc dot gnu dot org
2009-04-24  9:24 ` rguenth at gcc dot gnu dot org
2009-04-24  9:25 ` rguenth at gcc dot gnu dot org
2009-06-24  7:49 ` steven at gcc dot gnu dot org
2009-06-24  9:15 ` rguenth at gcc dot gnu dot org
2009-09-17 10:25 ` ubizjak at gmail dot com
2010-05-07  2:32 ` sandra at codesourcery dot com
2010-05-08  3:44 ` sandra at codesourcery dot com
2010-05-08 15:54 ` sandra at gcc dot gnu dot org
2010-05-24 13:22 ` sandra at codesourcery dot com
2010-05-25  8:12 ` rguenther at suse dot de
2010-06-01  2:24 ` sandra at codesourcery dot com
2010-06-08 18:16 ` sandra 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).