From patchwork Tue Jan 23 13:23:32 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Biener X-Patchwork-Id: 864782 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-471879-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="lsCxmlqS"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3zQpsX6Xzxz9t3M for ; Wed, 24 Jan 2018 00:23:43 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:subject:message-id:mime-version:content-type; q=dns; s= default; b=XcVow35IitO7vILNe+G5kqnGfBHZLcCZznxOK0nvUhikVxtBQsSys j0knpsKFEQdPInhMFDGwlAsOjiF4132uBVnkwTVKrTML9fqIcFCLQAJzuN7m98l2 A1nv1G8R3R2s0AM66mVaigDi/KDTuOxHDaWrjBPkIljdSJs6KqvaRE= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:subject:message-id:mime-version:content-type; s= default; bh=09sV0FWn5b6qab9HwMdEz2eI9lU=; b=lsCxmlqSz2lbsFhGVG0V 7q716+SYFfxgEm9q83ZVtbstwBNbUYnCde4QKwTMCAgf7CSwGTTE5+xy5HnU6IYp uXJK46kSsBIdngr28cZQfiXxf32KxtzmbFws0vQxpBEtxWWFLp1nVyRXrb9lPQzt IxIiyyrqwmFYtjyUJreh5y0= Received: (qmail 94166 invoked by alias); 23 Jan 2018 13:23:36 -0000 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 Received: (qmail 94146 invoked by uid 89); 23 Jan 2018 13:23:36 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-10.6 required=5.0 tests=BAYES_00, GIT_PATCH_2, GIT_PATCH_3, KAM_ASCII_DIVIDERS, KAM_NUMSUBJECT, SPF_PASS, T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 spammy=our X-HELO: mx2.suse.de Received: from mx2.suse.de (HELO mx2.suse.de) (195.135.220.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 23 Jan 2018 13:23:34 +0000 Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id C80E2AE29 for ; Tue, 23 Jan 2018 13:23:32 +0000 (UTC) Date: Tue, 23 Jan 2018 14:23:32 +0100 (CET) From: Richard Biener To: gcc-patches@gcc.gnu.org Subject: [PATCH] Fix PR82819 Message-ID: User-Agent: Alpine 2.20 (LSU 67 2015-01-07) MIME-Version: 1.0 This fixes a GRAPHITE code-generation issue by eliding ISL AST plus for large power-of-two values that don't affect the result. I intentionally didn't extend this to other values with the same property as I'd like to see testcases. Bootstrap and regtest running on x86_64-unknown-linux-gnu. Richard. 2018-01-23 Richard Biener PR tree-optimization/82819 * graphite-isl-ast-to-gimple.c (binary_op_to_tree): Avoid code generating pluses that are no-ops in the target precision. * gcc.dg/graphite/pr82819.c: New testcase. Index: gcc/graphite-isl-ast-to-gimple.c =================================================================== --- gcc/graphite-isl-ast-to-gimple.c (revision 256977) +++ gcc/graphite-isl-ast-to-gimple.c (working copy) @@ -326,7 +326,8 @@ binary_op_to_tree (tree type, __isl_take /* From our constraint generation we may get modulo operations that we cannot represent explicitely but that are no-ops for TYPE. Elide those. */ - if (expr_type == isl_ast_op_pdiv_r + if ((expr_type == isl_ast_op_pdiv_r + || expr_type == isl_ast_op_add) && isl_ast_expr_get_type (arg_expr) == isl_ast_expr_int && (wi::exact_log2 (widest_int_from_isl_expr_int (arg_expr)) >= TYPE_PRECISION (type))) Index: gcc/testsuite/gcc.dg/graphite/pr82819.c =================================================================== --- gcc/testsuite/gcc.dg/graphite/pr82819.c (nonexistent) +++ gcc/testsuite/gcc.dg/graphite/pr82819.c (working copy) @@ -0,0 +1,22 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -floop-nest-optimize" } */ + +short int *ts; + +void +c2 (unsigned long long int s4, int ns) +{ + short int *b2 = (short int *)&ns; + + while (ns != 0) + { + int xn; + + for (xn = 0; xn < 3; ++xn) + for (*b2 = 0; *b2 < 2; ++*b2) + s4 += xn; + if (s4 != 0) + b2 = ts; + ++ns; + } +}