public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
From: Richard Biener <rguenth@gcc.gnu.org>
To: gcc-cvs@gcc.gnu.org
Subject: [gcc r11-9688] tree-optimization/104931 - mitigate niter analysis issue
Date: Wed, 23 Mar 2022 14:08:07 +0000 (GMT)	[thread overview]
Message-ID: <20220323140807.07E913858C50@sourceware.org> (raw)

https://gcc.gnu.org/g:d1f4dfd409dedf4d00ca7be001cf757d0d6e82f4

commit r11-9688-gd1f4dfd409dedf4d00ca7be001cf757d0d6e82f4
Author: Richard Biener <rguenther@suse.de>
Date:   Wed Mar 16 14:53:06 2022 +0100

    tree-optimization/104931 - mitigate niter analysis issue
    
    The following backports a pointer associating pattern from trunk
    that mitigates an issue with number_of_iterations_lt_to_ne in
    which context we fail to fold a comparison but succeed in folding
    a related subtraction.  In the failure mode this results in
    a loop wrongly assumed looping with a bogus number of iterations,
    resulting in crashing of the premake application on start.
    
    With the backported simplification we are able to fold the
    comparison and correctly compute the loop as not iterating.
    
    I have failed to create a standalone testcase.  I belive part
    of the issue is still latent but I have failed to nail down
    the issue exactly.  Still I believe the backporting of the
    mitigation patch is the most sensible and safe thing at this
    point.
    
    2022-03-16  Richard Biener  <rguenther@suse.de>
    
            PR tree-optimization/104931
            * match.pd ((ptr) (x p+ y) p+ z -> (ptr) (x p+ (y + z))): New GENERIC
            simplification.

Diff:
---
 gcc/match.pd | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/gcc/match.pd b/gcc/match.pd
index 05a08d0f96a..a005dcd42bd 100644
--- a/gcc/match.pd
+++ b/gcc/match.pd
@@ -1997,6 +1997,11 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT)
 (simplify
   (pointer_plus (pointer_plus:s @0 @1) @3)
   (pointer_plus @0 (plus @1 @3)))
+#if GENERIC
+(simplify
+  (pointer_plus (convert:s (pointer_plus:s @0 @1)) @3)
+  (convert:type (pointer_plus @0 (plus @1 @3))))
+#endif
 
 /* Pattern match
      tem1 = (long) ptr1;


                 reply	other threads:[~2022-03-23 14:08 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20220323140807.07E913858C50@sourceware.org \
    --to=rguenth@gcc.gnu.org \
    --cc=gcc-cvs@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).