public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug middle-end/31531] A microoptimization of isnegative of signed integer
       [not found] <bug-31531-4@http.gcc.gnu.org/bugzilla/>
@ 2011-07-18 22:48 ` pinskia at gcc dot gnu.org
  2012-02-12  4:36 ` pinskia at gcc dot gnu.org
                   ` (16 subsequent siblings)
  17 siblings, 0 replies; 21+ messages in thread
From: pinskia at gcc dot gnu.org @ 2011-07-18 22:48 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |TREE

--- Comment #5 from Andrew Pinski <pinskia at gcc dot gnu.org> 2011-07-18 22:46:55 UTC ---
All the functions produce the same assembler output in 4.6.1 on x86.  Only
isnegative_optimized_4 produces a difference on some targets (and a difference
IR coming into expand).


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

* [Bug middle-end/31531] A microoptimization of isnegative of signed integer
       [not found] <bug-31531-4@http.gcc.gnu.org/bugzilla/>
  2011-07-18 22:48 ` [Bug middle-end/31531] A microoptimization of isnegative of signed integer pinskia at gcc dot gnu.org
@ 2012-02-12  4:36 ` pinskia at gcc dot gnu.org
  2012-02-12  4:37 ` pinskia at gcc dot gnu.org
                   ` (15 subsequent siblings)
  17 siblings, 0 replies; 21+ messages in thread
From: pinskia at gcc dot gnu.org @ 2012-02-12  4:36 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #6 from Andrew Pinski <pinskia at gcc dot gnu.org> 2012-02-12 04:35:53 UTC ---
The shortest testcase for the problem function:
int isnegative_optimized_4(unsigned int X) {
   int result; // Y is the conditional expression of if-else.
   if ((~X) >> 31) result = 0;
   else            result = 1;
   return result;
}

We need to combine the following gimple:
  D.2293_3 = ~X_2(D);
  D.2294_4 = (int) D.2293_3;
  D.2424_9 = D.2294_4 >= 0;


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

* [Bug middle-end/31531] A microoptimization of isnegative of signed integer
       [not found] <bug-31531-4@http.gcc.gnu.org/bugzilla/>
  2011-07-18 22:48 ` [Bug middle-end/31531] A microoptimization of isnegative of signed integer pinskia at gcc dot gnu.org
  2012-02-12  4:36 ` pinskia at gcc dot gnu.org
@ 2012-02-12  4:37 ` pinskia at gcc dot gnu.org
  2012-02-12  4:39 ` pinskia at gcc dot gnu.org
                   ` (14 subsequent siblings)
  17 siblings, 0 replies; 21+ messages in thread
From: pinskia at gcc dot gnu.org @ 2012-02-12  4:37 UTC (permalink / raw)
  To: gcc-bugs

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

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

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

--- Comment #7 from Andrew Pinski <pinskia at gcc dot gnu.org> 2012-02-12 04:37:08 UTC ---
Note:
  D.2424_9 = D.2294_4 >= 0;
is the same as:
  D.2424_9 = D.2294_4 < 0;


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

* [Bug middle-end/31531] A microoptimization of isnegative of signed integer
       [not found] <bug-31531-4@http.gcc.gnu.org/bugzilla/>
                   ` (2 preceding siblings ...)
  2012-02-12  4:37 ` pinskia at gcc dot gnu.org
@ 2012-02-12  4:39 ` pinskia at gcc dot gnu.org
  2012-02-12 22:58 ` pinskia at gcc dot gnu.org
                   ` (13 subsequent siblings)
  17 siblings, 0 replies; 21+ messages in thread
From: pinskia at gcc dot gnu.org @ 2012-02-12  4:39 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #8 from Andrew Pinski <pinskia at gcc dot gnu.org> 2012-02-12 04:39:01 UTC ---
forwprop already handles:
int f(int a)
{
  int b = ~a;
  return b<0;
}

It just needs to handle:
int f(unsigned a)
{
  int b = ~a;
  return b<0;
}


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

* [Bug middle-end/31531] A microoptimization of isnegative of signed integer
       [not found] <bug-31531-4@http.gcc.gnu.org/bugzilla/>
                   ` (3 preceding siblings ...)
  2012-02-12  4:39 ` pinskia at gcc dot gnu.org
@ 2012-02-12 22:58 ` pinskia at gcc dot gnu.org
  2012-02-13  0:44 ` pinskia at gcc dot gnu.org
                   ` (12 subsequent siblings)
  17 siblings, 0 replies; 21+ messages in thread
From: pinskia at gcc dot gnu.org @ 2012-02-12 22:58 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #9 from Andrew Pinski <pinskia at gcc dot gnu.org> 2012-02-12 22:58:41 UTC ---
(In reply to comment #8)
> forwprop already handles:
> int f(int a)
> {
>   int b = ~a;
>   return b<0;
> }
> 
> It just needs to handle:
> int f(unsigned a)
> {
>   int b = ~a;
>   return b<0;
> }

forward_propagate_into_comparison only handles combing of two SSA_NAMEs, it
could handle dealing with a conversion also.


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

* [Bug middle-end/31531] A microoptimization of isnegative of signed integer
       [not found] <bug-31531-4@http.gcc.gnu.org/bugzilla/>
                   ` (4 preceding siblings ...)
  2012-02-12 22:58 ` pinskia at gcc dot gnu.org
@ 2012-02-13  0:44 ` pinskia at gcc dot gnu.org
  2012-02-13  6:30 ` pinskia at gcc dot gnu.org
                   ` (11 subsequent siblings)
  17 siblings, 0 replies; 21+ messages in thread
From: pinskia at gcc dot gnu.org @ 2012-02-13  0:44 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #10 from Andrew Pinski <pinskia at gcc dot gnu.org> 2012-02-13 00:44:11 UTC ---
I have a patch which adds this optimization to fold.  And a partial patch which
adds some of it to forwprop but that fails because we have to create a temp
variable.


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

* [Bug middle-end/31531] A microoptimization of isnegative of signed integer
       [not found] <bug-31531-4@http.gcc.gnu.org/bugzilla/>
                   ` (5 preceding siblings ...)
  2012-02-13  0:44 ` pinskia at gcc dot gnu.org
@ 2012-02-13  6:30 ` pinskia at gcc dot gnu.org
  2012-02-13  7:47 ` pinskia at gcc dot gnu.org
                   ` (10 subsequent siblings)
  17 siblings, 0 replies; 21+ messages in thread
From: pinskia at gcc dot gnu.org @ 2012-02-13  6:30 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #11 from Andrew Pinski <pinskia at gcc dot gnu.org> 2012-02-13 06:30:29 UTC ---
I have a full patch now which also handles PR 14792 once that folding is
included in fold.


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

* [Bug middle-end/31531] A microoptimization of isnegative of signed integer
       [not found] <bug-31531-4@http.gcc.gnu.org/bugzilla/>
                   ` (6 preceding siblings ...)
  2012-02-13  6:30 ` pinskia at gcc dot gnu.org
@ 2012-02-13  7:47 ` pinskia at gcc dot gnu.org
  2012-02-14  3:59 ` pinskia at gcc dot gnu.org
                   ` (9 subsequent siblings)
  17 siblings, 0 replies; 21+ messages in thread
From: pinskia at gcc dot gnu.org @ 2012-02-13  7:47 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #12 from Andrew Pinski <pinskia at gcc dot gnu.org> 2012-02-13 07:46:45 UTC ---
Created attachment 26645
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=26645
Patch which fixes the problem (well the fold-const.c is really only needed for
the original testcase)

ChangeLog:
* fold-const.c (fold_comparison): Handle ((CAST)~X).
* tree-ssa-forwprop.c (combine_cond_expr_cond): Swap operands so
that fold_binary_loc would not return a non-folded tree.
Don't call canonicalize_cond_expr_cond.
(forward_propagate_into_comparison_1): Also combine casts into the comparisons.
(expand_possible_comparison): New function.
(forward_propagate_into_comparison): Call expand_possible_comparison.
(forward_propagate_into_gimple_cond): Take also a gsi.
Call expand_possible_comparison.
(forward_propagate_into_cond): Call expand_possible_comparison.
(ssa_forward_propagate_and_combine): Update call to
forward_propagate_into_gimple_cond.


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

* [Bug middle-end/31531] A microoptimization of isnegative of signed integer
       [not found] <bug-31531-4@http.gcc.gnu.org/bugzilla/>
                   ` (7 preceding siblings ...)
  2012-02-13  7:47 ` pinskia at gcc dot gnu.org
@ 2012-02-14  3:59 ` pinskia at gcc dot gnu.org
  2014-10-31  4:02 ` pinskia at gcc dot gnu.org
                   ` (8 subsequent siblings)
  17 siblings, 0 replies; 21+ messages in thread
From: pinskia at gcc dot gnu.org @ 2012-02-14  3:59 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #13 from Andrew Pinski <pinskia at gcc dot gnu.org> 2012-02-14 03:59:12 UTC ---
I committed the branch to the git only branch pinskia/treecombine.  The only
"regression" is gcc.target/i386/umod-3.c.  This is not really a regression but
rather a testcase issue as we produce better code and not produce a division at
all.


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

* [Bug middle-end/31531] A microoptimization of isnegative of signed integer
       [not found] <bug-31531-4@http.gcc.gnu.org/bugzilla/>
                   ` (8 preceding siblings ...)
  2012-02-14  3:59 ` pinskia at gcc dot gnu.org
@ 2014-10-31  4:02 ` pinskia at gcc dot gnu.org
  2021-06-03  8:58 ` pinskia at gcc dot gnu.org
                   ` (7 subsequent siblings)
  17 siblings, 0 replies; 21+ 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=31531
Bug 31531 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] 21+ messages in thread

* [Bug middle-end/31531] A microoptimization of isnegative of signed integer
       [not found] <bug-31531-4@http.gcc.gnu.org/bugzilla/>
                   ` (9 preceding siblings ...)
  2014-10-31  4:02 ` pinskia at gcc dot gnu.org
@ 2021-06-03  8:58 ` pinskia at gcc dot gnu.org
  2021-11-20  7:23 ` pinskia at gcc dot gnu.org
                   ` (6 subsequent siblings)
  17 siblings, 0 replies; 21+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-06-03  8:58 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=31531

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |ASSIGNED

--- Comment #15 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
(In reply to Andrew Pinski from comment #14)
> My patch needs to be re-written to use match.pd instead.

I am going to update it.

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

* [Bug middle-end/31531] A microoptimization of isnegative of signed integer
       [not found] <bug-31531-4@http.gcc.gnu.org/bugzilla/>
                   ` (10 preceding siblings ...)
  2021-06-03  8:58 ` pinskia at gcc dot gnu.org
@ 2021-11-20  7:23 ` pinskia at gcc dot gnu.org
  2021-11-20  8:11 ` pinskia at gcc dot gnu.org
                   ` (5 subsequent siblings)
  17 siblings, 0 replies; 21+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-11-20  7:23 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=31531

--- Comment #16 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
The only patch which is needed now:
diff --git a/gcc/match.pd b/gcc/match.pd
index 37c5be9e5f4..ca6c9eff624 100644
--- a/gcc/match.pd
+++ b/gcc/match.pd
@@ -4729,10 +4729,11 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT)
 (for cmp (simple_comparison)
      scmp (swapped_simple_comparison)
  (simplify
-  (cmp (bit_not@2 @0) CONSTANT_CLASS_P@1)
+  (cmp (nop_convert?:s (bit_not@2 @0)) CONSTANT_CLASS_P@1)
   (if (single_use (@2)
        && (TREE_CODE (@1) == INTEGER_CST || TREE_CODE (@1) == VECTOR_CST))
-   (scmp @0 (bit_not @1)))))
+   (with { tree type1 = TREE_TYPE (@1); }
+    (scmp (convert:type1 @0) (bit_not @1))))))

 (for cmp (simple_comparison)
  /* Fold (double)float1 CMP (double)float2 into float1 CMP float2.  */

I will add a testcase and submit it in a few.

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

* [Bug middle-end/31531] A microoptimization of isnegative of signed integer
       [not found] <bug-31531-4@http.gcc.gnu.org/bugzilla/>
                   ` (11 preceding siblings ...)
  2021-11-20  7:23 ` pinskia at gcc dot gnu.org
@ 2021-11-20  8:11 ` pinskia at gcc dot gnu.org
  2021-11-21 14:37 ` pinskia at gcc dot gnu.org
                   ` (4 subsequent siblings)
  17 siblings, 0 replies; 21+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-11-20  8:11 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=31531

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
  Attachment #26645|0                           |1
        is obsolete|                            |

--- Comment #17 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Created attachment 51841
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=51841&action=edit
Patch which I am testing

Attached patch which I am testing. should resolve this fully.

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

* [Bug middle-end/31531] A microoptimization of isnegative of signed integer
       [not found] <bug-31531-4@http.gcc.gnu.org/bugzilla/>
                   ` (12 preceding siblings ...)
  2021-11-20  8:11 ` pinskia at gcc dot gnu.org
@ 2021-11-21 14:37 ` pinskia at gcc dot gnu.org
  2023-10-15 20:55 ` pinskia at gcc dot gnu.org
                   ` (3 subsequent siblings)
  17 siblings, 0 replies; 21+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-11-21 14:37 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=31531

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
                URL|                            |https://gcc.gnu.org/piperma
                   |                            |il/gcc-patches/2021-Novembe
                   |                            |r/585088.html
           Keywords|                            |patch

--- Comment #18 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Patch posted:
https://gcc.gnu.org/pipermail/gcc-patches/2021-November/585088.html

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

* [Bug middle-end/31531] A microoptimization of isnegative of signed integer
       [not found] <bug-31531-4@http.gcc.gnu.org/bugzilla/>
                   ` (13 preceding siblings ...)
  2021-11-21 14:37 ` pinskia at gcc dot gnu.org
@ 2023-10-15 20:55 ` pinskia at gcc dot gnu.org
  2023-10-16  2:34 ` pinskia at gcc dot gnu.org
                   ` (2 subsequent siblings)
  17 siblings, 0 replies; 21+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-10-15 20:55 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=31531

--- Comment #19 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Created attachment 56119
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=56119&action=edit
testcase from the original attachment

For easier access, I posting this here so don't need to untar the file.

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

* [Bug middle-end/31531] A microoptimization of isnegative of signed integer
       [not found] <bug-31531-4@http.gcc.gnu.org/bugzilla/>
                   ` (14 preceding siblings ...)
  2023-10-15 20:55 ` pinskia at gcc dot gnu.org
@ 2023-10-16  2:34 ` pinskia at gcc dot gnu.org
  2023-10-16 17:01 ` cvs-commit at gcc dot gnu.org
  2023-10-16 17:03 ` pinskia at gcc dot gnu.org
  17 siblings, 0 replies; 21+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-10-16  2:34 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=31531

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
                URL|https://gcc.gnu.org/piperma |https://gcc.gnu.org/piperma
                   |il/gcc-patches/2021-Novembe |il/gcc-patches/2023-October
                   |r/585088.html               |/633090.html

--- Comment #20 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Updated patch:
https://gcc.gnu.org/pipermail/gcc-patches/2023-October/633090.html

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

* [Bug middle-end/31531] A microoptimization of isnegative of signed integer
       [not found] <bug-31531-4@http.gcc.gnu.org/bugzilla/>
                   ` (15 preceding siblings ...)
  2023-10-16  2:34 ` pinskia at gcc dot gnu.org
@ 2023-10-16 17:01 ` cvs-commit at gcc dot gnu.org
  2023-10-16 17:03 ` pinskia at gcc dot gnu.org
  17 siblings, 0 replies; 21+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-10-16 17:01 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=31531

--- Comment #21 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The trunk branch has been updated by Andrew Pinski <pinskia@gcc.gnu.org>:

https://gcc.gnu.org/g:29a4453c7b8a86d242dab89b9e4d222749fd911e

commit r14-4661-g29a4453c7b8a86d242dab89b9e4d222749fd911e
Author: Andrew Pinski <pinskia@gmail.com>
Date:   Sun Oct 15 15:18:42 2023 -0700

    [PR31531] MATCH: Improve ~a < ~b and ~a < CST, allow a nop cast inbetween ~
and a/b

    Currently we able to simplify `~a CMP ~b` to `b CMP a` but we should allow
a nop
    conversion in between the `~` and the `a` which can show up. A similarly
thing should
    be done for `~a CMP CST`.

    I had originally submitted the `~a CMP CST` case as
    https://gcc.gnu.org/pipermail/gcc-patches/2021-November/585088.html;
    I noticed we should do the same thing for the `~a CMP ~b` case and combined
    it with that one here.

    OK? Bootstrapped and tested on x86_64-linux-gnu with no regressions.

            PR tree-optimization/31531

    gcc/ChangeLog:

            * match.pd (~X op ~Y): Allow for an optional nop convert.
            (~X op C): Likewise.

    gcc/testsuite/ChangeLog:

            * gcc.dg/tree-ssa/pr31531-1.c: New test.
            * gcc.dg/tree-ssa/pr31531-2.c: New test.

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

* [Bug middle-end/31531] A microoptimization of isnegative of signed integer
       [not found] <bug-31531-4@http.gcc.gnu.org/bugzilla/>
                   ` (16 preceding siblings ...)
  2023-10-16 17:01 ` cvs-commit at gcc dot gnu.org
@ 2023-10-16 17:03 ` pinskia at gcc dot gnu.org
  17 siblings, 0 replies; 21+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-10-16 17:03 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=31531

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

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

--- Comment #22 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Fixed.

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

* [Bug middle-end/31531] A microoptimization of isnegative of signed integer
  2007-04-10 18:05 [Bug c/31531] New: A microoptimization of isnegative or greaterthan2millions JCPiza at gmail dot com
  2007-04-10 18:17 ` [Bug middle-end/31531] A microoptimization of isnegative of signed integer pinskia at gcc dot gnu dot org
  2007-04-10 18:20 ` pinskia at gcc dot gnu dot org
@ 2007-04-15  5:43 ` pinskia at gcc dot gnu dot org
  2 siblings, 0 replies; 21+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2007-04-15  5:43 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from pinskia at gcc dot gnu dot org  2007-04-15 06:43 -------
There are a couple of ways of fixing this bug, folding while going out of ssa. 
Doing a tree combined which is PR 15459.  Or the patch which I attached.


-- 

pinskia at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
  BugsThisDependsOn|                            |15459
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|0                           |1
   Last reconfirmed|0000-00-00 00:00:00         |2007-04-15 06:43:24
               date|                            |


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


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

* [Bug middle-end/31531] A microoptimization of isnegative of signed integer
  2007-04-10 18:05 [Bug c/31531] New: A microoptimization of isnegative or greaterthan2millions JCPiza at gmail dot com
  2007-04-10 18:17 ` [Bug middle-end/31531] A microoptimization of isnegative of signed integer pinskia at gcc dot gnu dot org
@ 2007-04-10 18:20 ` pinskia at gcc dot gnu dot org
  2007-04-15  5:43 ` pinskia at gcc dot gnu dot org
  2 siblings, 0 replies; 21+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2007-04-10 18:20 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from pinskia at gcc dot gnu dot org  2007-04-10 19:20 -------
A quick patch like:
Index: expr.c
===================================================================
--- expr.c      (revision 123691)
+++ expr.c      (working copy)
@@ -6828,7 +6828,7 @@
   tree type;
   int unsignedp;
   enum machine_mode mode;
-  enum tree_code code = TREE_CODE (exp);
+  enum tree_code code;
   optab this_optab;
   rtx subtarget, original_target;
   int ignore;
@@ -6840,6 +6840,9 @@
                                                                  type)   \
                                 : (expr))

+  if (TREE_CODE (exp) != COND_EXPR && !GIMPLE_TUPLE_P (exp))
+    exp = fold (exp);
+  code = TREE_CODE(exp);
   if (GIMPLE_STMT_P (exp))
     {
       type = void_type_node;



Makes all functions emit the same code.


-- 


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


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

* [Bug middle-end/31531] A microoptimization of isnegative of signed integer
  2007-04-10 18:05 [Bug c/31531] New: A microoptimization of isnegative or greaterthan2millions JCPiza at gmail dot com
@ 2007-04-10 18:17 ` pinskia at gcc dot gnu dot org
  2007-04-10 18:20 ` pinskia at gcc dot gnu dot org
  2007-04-15  5:43 ` pinskia at gcc dot gnu dot org
  2 siblings, 0 replies; 21+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2007-04-10 18:17 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from pinskia at gcc dot gnu dot org  2007-04-10 19:17 -------
What the real issue is that we don't fold !(x >= 0) into x < 0 before
expanding.


-- 

pinskia at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
          Component|c                           |middle-end
           Keywords|                            |missed-optimization
            Summary|A microoptimization of      |A microoptimization of
                   |isnegative or               |isnegative of signed integer
                   |greaterthan2millions.       |


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


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

end of thread, other threads:[~2023-10-16 17:03 UTC | newest]

Thread overview: 21+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <bug-31531-4@http.gcc.gnu.org/bugzilla/>
2011-07-18 22:48 ` [Bug middle-end/31531] A microoptimization of isnegative of signed integer pinskia at gcc dot gnu.org
2012-02-12  4:36 ` pinskia at gcc dot gnu.org
2012-02-12  4:37 ` pinskia at gcc dot gnu.org
2012-02-12  4:39 ` pinskia at gcc dot gnu.org
2012-02-12 22:58 ` pinskia at gcc dot gnu.org
2012-02-13  0:44 ` pinskia at gcc dot gnu.org
2012-02-13  6:30 ` pinskia at gcc dot gnu.org
2012-02-13  7:47 ` pinskia at gcc dot gnu.org
2012-02-14  3:59 ` pinskia at gcc dot gnu.org
2014-10-31  4:02 ` pinskia at gcc dot gnu.org
2021-06-03  8:58 ` pinskia at gcc dot gnu.org
2021-11-20  7:23 ` pinskia at gcc dot gnu.org
2021-11-20  8:11 ` pinskia at gcc dot gnu.org
2021-11-21 14:37 ` pinskia at gcc dot gnu.org
2023-10-15 20:55 ` pinskia at gcc dot gnu.org
2023-10-16  2:34 ` pinskia at gcc dot gnu.org
2023-10-16 17:01 ` cvs-commit at gcc dot gnu.org
2023-10-16 17:03 ` pinskia at gcc dot gnu.org
2007-04-10 18:05 [Bug c/31531] New: A microoptimization of isnegative or greaterthan2millions JCPiza at gmail dot com
2007-04-10 18:17 ` [Bug middle-end/31531] A microoptimization of isnegative of signed integer pinskia at gcc dot gnu dot org
2007-04-10 18:20 ` pinskia at gcc dot gnu dot org
2007-04-15  5:43 ` 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).