public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Richard Biener <rguenther@suse.de>
To: gcc-patches@gcc.gnu.org
Subject: [PATCH] Fix PR68026
Date: Wed, 21 Oct 2015 08:03:00 -0000	[thread overview]
Message-ID: <alpine.LSU.2.11.1510210954270.16509@zhemvz.fhfr.qr> (raw)


This fixes a missed optimization in CCP bit-propagation where we
lost the fact of upper zero bits of unsigned VARYING values
(the wide-int conversion made somewhat of a mess of all this).

Bootstrapped and tested on x86_64-unknown-linux-gnu, applied to trunk.

Richard.

2015-10-21  Richard Biener  <rguenther@suse.de>

	PR tree-optimization/68026
	* tree-ssa-ccp.c (get_value_for_expr): Zero-extend mask for
	unsigned VARYING values.

	* gcc.dg/tree-ssa/ssa-ccp-39.c: New testcase.

Index: gcc/tree-ssa-ccp.c
===================================================================
*** gcc/tree-ssa-ccp.c	(revision 229031)
--- gcc/tree-ssa-ccp.c	(working copy)
*************** get_value_for_expr (tree expr, bool for_
*** 629,634 ****
--- 629,639 ----
        val.mask = -1;
        val.value = NULL_TREE;
      }
+ 
+   if (val.lattice_val == VARYING
+       && TYPE_UNSIGNED (TREE_TYPE (expr)))
+     val.mask = wi::zext (val.mask, TYPE_PRECISION (TREE_TYPE (expr)));
+ 
    return val;
  }
  
Index: gcc/testsuite/gcc.dg/tree-ssa/ssa-ccp-39.c
===================================================================
*** gcc/testsuite/gcc.dg/tree-ssa/ssa-ccp-39.c	(revision 0)
--- gcc/testsuite/gcc.dg/tree-ssa/ssa-ccp-39.c	(working copy)
***************
*** 0 ****
--- 1,19 ----
+ /* { dg-do run } */
+ /* { dg-options "-O -fdump-tree-ccp1" } */
+ 
+ int main (void)
+ {
+   volatile int x1 = 1;
+   volatile int x2 = 1;
+   int x3 = 2;
+   int t = 1;
+ 
+   t = 3<=(x2|1|x3|x1-1U);
+ 
+   if (t == 1) {} 
+   else { __builtin_abort(); }
+ 
+   return 0;
+ }
+ 
+ /* { dg-final { scan-tree-dump-not "abort" "ccp1" } } */

                 reply	other threads:[~2015-10-21  7:55 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=alpine.LSU.2.11.1510210954270.16509@zhemvz.fhfr.qr \
    --to=rguenther@suse.de \
    --cc=gcc-patches@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).