public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "652023330028 at smail dot nju.edu.cn" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug tree-optimization/111780] New: Missed optimization of '(t*4)/(t*2) -> 2'
Date: Thu, 12 Oct 2023 07:56:54 +0000	[thread overview]
Message-ID: <bug-111780-4@http.gcc.gnu.org/bugzilla/> (raw)

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

            Bug ID: 111780
           Summary: Missed optimization of '(t*4)/(t*2) -> 2'
           Product: gcc
           Version: 14.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: 652023330028 at smail dot nju.edu.cn
  Target Milestone: ---

Hello, we found some optimizations (regarding Arithmetic optimization) that GCC
may have missed. We would greatly appreicate if you can take a look and let us
know what you think.

Given the following code:
https://godbolt.org/z/G9rWK7c3q
int n1;
void func1(int a){
    if(a>1&&a<4) n1=(a+a+a+a)/(a+a);
}

Different from PR 111718, this missed optimization appears to be due to a
missed pattern: (t*4)/(t*2) -> 2

  # DEBUG BEGIN_STMT
  # RANGE [irange] int [8, 8][12, 12] NONZERO 0xc
  _3 = a_7(D) * 4;
  # RANGE [irange] int [4, 4][6, 6] NONZERO 0x6
  _4 = a_7(D) * 2;
  # RANGE [irange] int [1, 3] NONZERO 0x3
  _5 = _3 / _4;
  # .MEM_9 = VDEF <.MEM_8(D)>
  n1D.2761 = _5;

Or a more general pattern: (t*m)/(t*n) -> m/n , where m and n are constants.

Thank you very much for your time and effort! We look forward to hearing from
you.

             reply	other threads:[~2023-10-12  7:56 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-12  7:56 652023330028 at smail dot nju.edu.cn [this message]
2023-10-12  8:34 ` [Bug tree-optimization/111780] " rguenth 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-111780-4@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).