From patchwork Fri Sep 24 04:55:53 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sebastian Pop X-Patchwork-Id: 65624 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 360EEB70DB for ; Fri, 24 Sep 2010 14:56:25 +1000 (EST) Received: (qmail 7819 invoked by alias); 24 Sep 2010 04:56:19 -0000 Received: (qmail 7811 invoked by uid 22791); 24 Sep 2010 04:56:18 -0000 X-SWARE-Spam-Status: No, hits=-1.9 required=5.0 tests=AWL, BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, TW_TM, T_TO_NO_BRKTS_FREEMAIL X-Spam-Check-By: sourceware.org Received: from mail-yx0-f175.google.com (HELO mail-yx0-f175.google.com) (209.85.213.175) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 24 Sep 2010 04:56:13 +0000 Received: by yxg6 with SMTP id 6so990905yxg.20 for ; Thu, 23 Sep 2010 21:56:11 -0700 (PDT) Received: by 10.100.206.8 with SMTP id d8mr590773ang.70.1285304171287; Thu, 23 Sep 2010 21:56:11 -0700 (PDT) Received: from napoca (cpe-70-120-196-107.austin.res.rr.com [70.120.196.107]) by mx.google.com with ESMTPS id d4sm2597430and.19.2010.09.23.21.56.09 (version=TLSv1/SSLv3 cipher=RC4-MD5); Thu, 23 Sep 2010 21:56:10 -0700 (PDT) Received: by napoca (sSMTP sendmail emulation); Thu, 23 Sep 2010 23:56:08 -0500 From: Sebastian Pop To: gcc-patches@gcc.gnu.org Cc: gcc-graphite@googlegroups.com, Sebastian Pop Subject: [PATCH] Fix miscompilation of 416.gamess. Date: Thu, 23 Sep 2010 23:55:53 -0500 Message-Id: <1285304153-28942-1-git-send-email-sebpop@gmail.com> X-IsSubscribed: yes 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 2010-09-23 Sebastian Pop * sese.h (scev_analyzable_p): Return false for real or floating point. Only handle INTEGRAL_TYPE_P and POINTER_TYPE_P. --- gcc/ChangeLog.graphite | 5 +++++ gcc/sese.h | 19 ++++++++++++++++--- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/gcc/ChangeLog.graphite b/gcc/ChangeLog.graphite index c63f2dc..b966a94 100644 --- a/gcc/ChangeLog.graphite +++ b/gcc/ChangeLog.graphite @@ -1,5 +1,10 @@ 2010-09-23 Sebastian Pop + * sese.h (scev_analyzable_p): Return false for real or floating + point. Only handle INTEGRAL_TYPE_P and POINTER_TYPE_P. + +2010-09-23 Sebastian Pop + PR middle-end/45758 * gfortran.dg/graphite/pr45758.f90: New. diff --git a/gcc/sese.h b/gcc/sese.h index 8277f68..61f3a17 100644 --- a/gcc/sese.h +++ b/gcc/sese.h @@ -386,9 +386,22 @@ nb_common_loops (sese region, gimple_bb_p gbb1, gimple_bb_p gbb2) static inline bool scev_analyzable_p (tree def, sese region) { - gimple stmt = SSA_NAME_DEF_STMT (def); - loop_p loop = loop_containing_stmt (stmt); - tree scev = scalar_evolution_in_region (region, loop, def); + loop_p loop; + tree scev; + tree type = TREE_TYPE (def); + + /* When Graphite generates code for a scev, the code generator + expresses the scev in function of a single induction variable. + This is unsafe for floating point computations, as it may replace + a floating point sum reduction with a multiplication. The + following test returns false for non integer types to avoid such + problems. */ + if (!INTEGRAL_TYPE_P (type) + && !POINTER_TYPE_P (type)) + return false; + + loop = loop_containing_stmt (SSA_NAME_DEF_STMT (def)); + scev = scalar_evolution_in_region (region, loop, def); return !chrec_contains_undetermined (scev) && TREE_CODE (scev) != SSA_NAME