public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/100958] New: two_value_replacement should move to match.pd
@ 2021-06-08  6:42 pinskia at gcc dot gnu.org
  2021-06-08  6:42 ` [Bug tree-optimization/100958] " pinskia at gcc dot gnu.org
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-06-08  6:42 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 100958
           Summary: two_value_replacement should move to match.pd
           Product: gcc
           Version: 12.0
            Status: UNCONFIRMED
          Keywords: missed-optimization
          Severity: enhancement
          Priority: P3
         Component: tree-optimization
          Assignee: pinskia at gcc dot gnu.org
          Reporter: pinskia at gcc dot gnu.org
  Target Milestone: ---

two_value_replacement can be fully implemented in match.pd now.
So it should move.  I did not do it originally but it.

Comment from two_value_replacement :
/* Optimize
   # x_5 in range [cst1, cst2] where cst2 = cst1 + 1
   if (x_5 op cstN) # where op is == or != and N is 1 or 2
     goto bb3;
   else
     goto bb4;
   bb3:
   bb4:
   # r_6 = PHI<cst3(2), cst4(3)> # where cst3 == cst4 + 1 or cst4 == cst3 + 1

   to r_6 = x_5 + (min (cst3, cst4) - cst1) or
   r_6 = (min (cst3, cst4) + cst1) - x_5 depending on op, N and which
   of cst3 and cst4 is smaller.  */

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

* [Bug tree-optimization/100958] two_value_replacement should move to match.pd
  2021-06-08  6:42 [Bug tree-optimization/100958] New: two_value_replacement should move to match.pd pinskia at gcc dot gnu.org
@ 2021-06-08  6:42 ` pinskia at gcc dot gnu.org
  2023-04-09 17:21 ` pinskia at gcc dot gnu.org
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-06-08  6:42 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Last reconfirmed|                            |2021-06-08
     Ever confirmed|0                           |1
             Status|UNCONFIRMED                 |ASSIGNED

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

* [Bug tree-optimization/100958] two_value_replacement should move to match.pd
  2021-06-08  6:42 [Bug tree-optimization/100958] New: two_value_replacement should move to match.pd pinskia at gcc dot gnu.org
  2021-06-08  6:42 ` [Bug tree-optimization/100958] " pinskia at gcc dot gnu.org
@ 2023-04-09 17:21 ` pinskia at gcc dot gnu.org
  2023-04-26  3:01 ` pinskia at gcc dot gnu.org
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-04-09 17:21 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Here is the start of the conversion to match.pd, there must be an easier way to
see the range too:
#if GIMPLE
/* Optimize
   x in range [cst1, cst2] where cst2 = cst1 + 1
   (x op CSTN) ? CST3 : CST4
   # where op is == or != and N is 1 or 2
   # where cst3 == cst4 + 1 or cst4 == cst3 + 1
   to x + (min (cst3, cst4) - cst1) or
  (min (cst3, cst4) + cst1) - x depending on op, N and which
   of cst3 and cst4 is smaller.  */
(for eqne (eq ne)
 (simplify
  (cond (eqne @0 INTEGER_CST@1) INTEGER_CST@2 INTEGER_CST@3)
  (if (tree_int_cst_lt (@2, @3)
       ? wi::to_widest (@2) + 1 != wi::to_widest (@3)
       : wi::to_widest (@3) + 1 != wi::to_widest (@2))
   (with { wide_int min, max;
           value_range r;
           get_range_query (cfun)->range_of_expr (r, lhs);

           if (r.kind () == VR_RANGE)
             {
               min = r.lower_bound ();
               max = r.upper_bound ();
             }
           else
             {
               int prec = TYPE_PRECISION (TREE_TYPE (lhs));
               signop sgn = TYPE_SIGN (TREE_TYPE (lhs));
               min = wi::min_value (prec, sgn);
               max = wi::max_value (prec, sgn);
             }
         }
    (if (min + 1 == max
         && (wi::to_wide (@1) == min
             || wi::to_wide (@1) == max))

#endif

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

* [Bug tree-optimization/100958] two_value_replacement should move to match.pd
  2021-06-08  6:42 [Bug tree-optimization/100958] New: two_value_replacement should move to match.pd pinskia at gcc dot gnu.org
  2021-06-08  6:42 ` [Bug tree-optimization/100958] " pinskia at gcc dot gnu.org
  2023-04-09 17:21 ` pinskia at gcc dot gnu.org
@ 2023-04-26  3:01 ` pinskia at gcc dot gnu.org
  2023-04-28 14:27 ` cvs-commit at gcc dot gnu.org
  2023-04-28 14:50 ` pinskia at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-04-26  3:01 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Created attachment 54923
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=54923&action=edit
Patch which is under testing

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

* [Bug tree-optimization/100958] two_value_replacement should move to match.pd
  2021-06-08  6:42 [Bug tree-optimization/100958] New: two_value_replacement should move to match.pd pinskia at gcc dot gnu.org
                   ` (2 preceding siblings ...)
  2023-04-26  3:01 ` pinskia at gcc dot gnu.org
@ 2023-04-28 14:27 ` cvs-commit at gcc dot gnu.org
  2023-04-28 14:50 ` pinskia at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-04-28 14:27 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 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:1dd154f6407658d46faa4d21bfec04fc2551506a

commit r14-338-g1dd154f6407658d46faa4d21bfec04fc2551506a
Author: Andrew Pinski <apinski@marvell.com>
Date:   Tue Apr 25 19:46:40 2023 -0700

    PHIOPT: Move two_value_replacement to match.pd

    This patch converts two_value_replacement function
    into a match.pd pattern.
    It is a direct translation with only one minor change,
    does not check for the {0,+-1} case as that is handled
    before in match.pd so there is no reason to do the extra
    check for it.

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

    gcc/ChangeLog:

            PR tree-optimization/100958
            * tree-ssa-phiopt.cc (two_value_replacement): Remove.
            (pass_phiopt::execute): Don't call two_value_replacement.
            * match.pd (a !=/== CST1 ? CST2 : CST3): Add pattern to
            handle what two_value_replacement did.

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

* [Bug tree-optimization/100958] two_value_replacement should move to match.pd
  2021-06-08  6:42 [Bug tree-optimization/100958] New: two_value_replacement should move to match.pd pinskia at gcc dot gnu.org
                   ` (3 preceding siblings ...)
  2023-04-28 14:27 ` cvs-commit at gcc dot gnu.org
@ 2023-04-28 14:50 ` pinskia at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-04-28 14:50 UTC (permalink / raw)
  To: gcc-bugs

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

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

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

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

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

end of thread, other threads:[~2023-04-28 14:50 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-08  6:42 [Bug tree-optimization/100958] New: two_value_replacement should move to match.pd pinskia at gcc dot gnu.org
2021-06-08  6:42 ` [Bug tree-optimization/100958] " pinskia at gcc dot gnu.org
2023-04-09 17:21 ` pinskia at gcc dot gnu.org
2023-04-26  3:01 ` pinskia at gcc dot gnu.org
2023-04-28 14:27 ` cvs-commit at gcc dot gnu.org
2023-04-28 14:50 ` pinskia at gcc dot gnu.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).