public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "pinskia at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug tree-optimization/106164] (a > b) & (a >= b) does not get optimized until reassoc1
Date: Sat, 02 Jul 2022 05:12:25 +0000	[thread overview]
Message-ID: <bug-106164-4-Rwk6crI2NU@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-106164-4@http.gcc.gnu.org/bugzilla/>

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

--- Comment #4 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
This is the match.pd code:
(for bitop (bit_and bit_ior)
 (for cmp (tcc_comparison)
  (for ocmp (tcc_comparison)
   (for ncmp (tcc_comparison)
    (simplify
     (bitop (cmp:c @0 @1) (ocmp @0 @1))
     (with {
#if GIMPLE
        location_t loc = UNKNOWN_LOCATION;
#endif
        tree t = combine_comparisons (loc,
                                      bitop == BIT_IOR_EXPR
                                       ? TRUTH_ORIF_EXPR : TRUTH_ANDIF_EXPR,
                                      cmp, ocmp,
                                      type, @0, @1);
      }
      (switch
       (if (GENERIC && t)
        {t;})
       (if (t && CONSTANT_CLASS_P (t))
        {t;})
       (if (t && TREE_CODE (t) == ncmp
            /* Even though combine_comparisons should
               return this, this is to double check. */
            && operand_equal_p (TREE_OPERAND (t, 0), @0)
            && operand_equal_p (TREE_OPERAND (t, 1), @1))
        (ncmp @0 @1)
       )
      )
     )
    )
   )
  )
 )
)

I am not a fan of it though, I think we should change combine_comparisons to
return the comparison code or true/false or error out.
The loc is due to combine_comparisons building the tree rather than match. The
same is true of the whole checking of the result. I am going to test this fully
and see if there is anything I need to change (there might be some testcases
which need to be "improved").

Also the whole ncmp for loop is still another issue which is a genmatch change
to allow a non-name to be there but that is so so much harder to fix and there
is already a case like that too.

  parent reply	other threads:[~2022-07-02  5:12 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-01 22:39 [Bug tree-optimization/106164] New: " pinskia at gcc dot gnu.org
2022-07-01 23:45 ` [Bug tree-optimization/106164] " pinskia at gcc dot gnu.org
2022-07-02  4:22 ` pinskia at gcc dot gnu.org
2022-07-02  4:23 ` pinskia at gcc dot gnu.org
2022-07-02  5:12 ` pinskia at gcc dot gnu.org [this message]
2022-07-04  6:38 ` rguenth at gcc dot gnu.org
2023-07-29 23:53 ` pinskia at gcc dot gnu.org
2023-07-30  3:00 ` pinskia at gcc dot gnu.org
2023-07-30  3:47 ` pinskia at gcc dot gnu.org
2023-07-30  5:09 ` pinskia at gcc dot gnu.org
2023-07-31  5:37 ` pinskia at gcc dot gnu.org
2023-07-31  7:08 ` rguenther at suse dot de
2023-07-31 17:12 ` cvs-commit at gcc dot gnu.org
2023-07-31 17:12 ` cvs-commit at gcc dot gnu.org
2023-09-14  0:09 ` pinskia at gcc dot gnu.org
2023-09-14  0:38 ` pinskia at gcc dot gnu.org
2023-09-14  5:34 ` pinskia at gcc dot gnu.org
2023-09-14 14:30 ` cvs-commit at gcc dot gnu.org
2023-09-14 14:36 ` pinskia at gcc dot gnu.org
2023-09-19  0:36 ` pinskia at gcc dot gnu.org
2023-09-19  2:46 ` pinskia at gcc dot gnu.org
2023-09-20 22:41 ` pinskia at gcc dot gnu.org
2023-09-26 15:01 ` cvs-commit at gcc dot gnu.org
2023-11-05  6:08 ` pinskia at gcc dot gnu.org
2023-11-05  6:10 ` pinskia at gcc dot gnu.org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-106164-4-Rwk6crI2NU@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).