From patchwork Mon Dec 13 13:40:26 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Monakov X-Patchwork-Id: 75353 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) by ozlabs.org (Postfix) with SMTP id E11ADB6F1E for ; Tue, 14 Dec 2010 00:40:37 +1100 (EST) Received: (qmail 9547 invoked by alias); 13 Dec 2010 13:40:35 -0000 Received: (qmail 9537 invoked by uid 22791); 13 Dec 2010 13:40:34 -0000 X-SWARE-Spam-Status: No, hits=-2.0 required=5.0 tests=AWL, BAYES_00, FSL_RU_URL, T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from smtp.ispras.ru (HELO smtp.ispras.ru) (83.149.198.201) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 13 Dec 2010 13:40:29 +0000 Received: from ispserv.ispras.ru (ispserv.ispras.ru [83.149.198.72]) by smtp.ispras.ru (Postfix) with ESMTP id AE3F25D40B0; Mon, 13 Dec 2010 16:34:32 +0300 (MSK) Received: from monoid.intra.ispras.ru (unknown [83.149.198.236]) by ispserv.ispras.ru (Postfix) with ESMTP id 718CA3FC48; Mon, 13 Dec 2010 16:40:26 +0300 (MSK) Date: Mon, 13 Dec 2010 16:40:26 +0300 (MSK) From: Alexander Monakov To: gcc-patches@gcc.gnu.org cc: Sebastian Pop Subject: [PR46761] graphite: fix testing of boundary wrapping Message-ID: User-Agent: Alpine 2.00 (LNX 1167 2008-08-23) MIME-Version: 1.0 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Hi, As indicated by the testcase, sometimes Graphite would generate wrong region guards if UB_ONE overflows, but does not become zero (i.e. it is signed). The patch changes the corresponding test to use TREE_OVERFLOW flag. Bootstrapped and regtested on x86_64-linux, OK for trunk? 2010-12-13 Alexander Monakov PR middle-end/46761 * graphite-clast-to-gimple.c (graphite_create_new_loop_guard): Use TREE_OVERFLOW_P to test overflow. testsuite: * gcc.dg/graphite/pr46761.c: New. diff --git a/gcc/graphite-clast-to-gimple.c b/gcc/graphite-clast-to-gimple.c index 4894b52..183dde7 100644 --- a/gcc/graphite-clast-to-gimple.c +++ b/gcc/graphite-clast-to-gimple.c @@ -985,7 +985,7 @@ graphite_create_new_loop_guard (sese region, edge entry_edge, : PLUS_EXPR, type, ub, one); /* When ub + 1 wraps around, use lb <= ub. */ - if (integer_zerop (ub_one)) + if (TREE_OVERFLOW_P (ub_one)) cond_expr = fold_build2 (LE_EXPR, boolean_type_node, lb, ub); else cond_expr = fold_build2 (LT_EXPR, boolean_type_node, lb, ub_one); diff --git a/gcc/testsuite/gcc.dg/graphite/pr46761.c b/gcc/testsuite/gcc.dg/graphite/pr46761.c new file mode 100644 index 0000000..f45398a --- /dev/null +++ b/gcc/testsuite/gcc.dg/graphite/pr46761.c @@ -0,0 +1,22 @@ +/* { dg-do run } */ +/* { dg-options "-O -fgraphite-identity" } */ + +#define N 128 + +int +main () +{ + int arr[N], i, s = 0; + for (i = 0; i < N; i++) + arr[i] = i; + + for (i = 0; i < N; i++) + if (arr[i] != i) + __builtin_abort (); + + for (i = 0; i < N; i++) + s += arr[i]; + if (s != (N * (N - 1)) / 2) + __builtin_abort (); + return 0; +}