SOURCES: gcc-pr28230.patch (NEW) - PR28230: fixes wrong code gener...

qrczak qrczak at pld-linux.org
Mon Oct 16 17:03:04 CEST 2006


Author: qrczak                       Date: Mon Oct 16 15:03:04 2006 GMT
Module: SOURCES                       Tag: HEAD
---- Log message:
- PR28230: fixes wrong code generation with -fwrapv

---- Files affected:
SOURCES:
   gcc-pr28230.patch (NONE -> 1.1)  (NEW)

---- Diffs:

================================================================
Index: SOURCES/gcc-pr28230.patch
diff -u /dev/null SOURCES/gcc-pr28230.patch:1.1
--- /dev/null	Mon Oct 16 17:03:04 2006
+++ SOURCES/gcc-pr28230.patch	Mon Oct 16 17:02:59 2006
@@ -0,0 +1,105 @@
+From gcc-patches-return-179804-listarch-gcc-patches=gcc dot gnu dot org at gcc dot gnu dot org Wed Oct 11 10:40:12 2006
+Return-Path: <gcc-patches-return-179804-listarch-gcc-patches=gcc dot gnu dot org at gcc dot gnu dot org>
+Delivered-To: listarch-gcc-patches at gcc dot gnu dot org
+Received: (qmail 10032 invoked by alias); 11 Oct 2006 10:40:11 -0000
+Received: (qmail 10012 invoked by uid 22791); 11 Oct 2006 10:40:05 -0000
+X-Spam-Check-By: sourceware.org
+Received: from cantor.suse.de (HELO mx1.suse.de) (195.135.220.2)     by sourceware.org (qpsmtpd/0.31) with ESMTP; Wed, 11 Oct 2006 10:39:55 +0000
+Received: from Relay1.suse.de (mail2.suse.de [195.135.221.8]) 	(using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) 	(No client certificate requested) 	by mx1.suse.de (Postfix) with ESMTP id 3390F11E4E 	for <gcc-patches at gcc.gnu.org>; Wed, 11 Oct 2006 12:39:52 +0200 (CEST)
+Date: Wed, 11 Oct 2006 12:40:33 +0200 (CEST)
+From: Richard Guenther <rguenther at suse dot de>
+To: gcc-patches at gcc dot gnu dot org
+Subject: [PATCH] Fix PR28230, wrong code with VRP and -fwrapv
+Message-ID: <Pine.LNX.4.64.0610111003170.3581 at zhemvz.fhfr.qr>
+MIME-Version: 1.0
+Content-Type: TEXT/PLAIN; charset=US-ASCII
+Mailing-List: contact gcc-patches-help at gcc dot gnu dot org; run by ezmlm
+Precedence: bulk
+List-Archive: <http://gcc.gnu.org/ml/gcc-patches/>
+List-Post: <mailto:gcc-patches at gcc dot gnu dot org>
+List-Help: <mailto:gcc-patches-help at gcc dot gnu dot org>
+Sender: gcc-patches-owner at gcc dot gnu dot org
+Delivered-To: mailing list gcc-patches at gcc dot gnu dot org
+
+
+This fixes PR28230, VRP was interestingly thinking that -frwapv is
+somehow special for combining value ranges in general.  But of course just
+"ignoring" overflow in [0, 65000] + [0, +Inf] is not yielding any
+useful value range.
+
+The fix for this is to move the flag_wrapv handling to the unsigned
+case.
+
+Bootstrapped and tested on x86_64-unknown-linux-gnu.
+
+Ok for mainline?
+
+Thanks,
+Richard.
+
+:ADDPATCH middle-end:
+
+2006-10-10  Richard Guenther  <rguenther at suse.de>
+
+	PR tree-optimization/28230
+	* tree-vrp.c (vrp_int_const_binop): Move flag_wrapv handling
+	to the correct place.
+
+	* gcc.dg/torture/pr28230.c: New testcase.
+
+
+Index: tree-vrp.c
+===================================================================
+*** tree-vrp.c	(revision 117629)
+--- tree-vrp.c	(working copy)
+*************** vrp_int_const_binop (enum tree_code code
+*** 1235,1248 ****
+  {
+    tree res;
+  
+!   if (flag_wrapv)
+!     return int_const_binop (code, val1, val2, 0);
+  
+    /* If we are not using wrapping arithmetic, operate symbolically
+       on -INF and +INF.  */
+!   res = int_const_binop (code, val1, val2, 0);
+! 
+!   if (TYPE_UNSIGNED (TREE_TYPE (val1)))
+      {
+        int checkz = compare_values (res, val1);
+        bool overflow = false;
+--- 1235,1246 ----
+  {
+    tree res;
+  
+!   res = int_const_binop (code, val1, val2, 0);
+  
+    /* If we are not using wrapping arithmetic, operate symbolically
+       on -INF and +INF.  */
+!   if (TYPE_UNSIGNED (TREE_TYPE (val1))
+!       || flag_wrapv)
+      {
+        int checkz = compare_values (res, val1);
+        bool overflow = false;
+
+/* { dg-do run } */
+/* { dg-options "-fwrapv" } */
+
+void foo( unsigned long long bb, unsigned short tn, unsigned e, unsigned* w );
+void foo( unsigned long long bb, unsigned short tn, unsigned e, unsigned* w )
+{
+        unsigned n = tn + bb;
+        do {
+                e = (e > n) ? e : *w;
+                n -= (e > n) ? n : e;
+                if (*w)
+                        *w = 0;
+        } while ( n );
+}
+int main()
+{
+        unsigned w = 0;
+        foo( 0, 0, 0, &w );
+        return 0;
+}
+
================================================================


More information about the pld-cvs-commit mailing list