From patchwork Fri Sep 28 16:59:53 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Botcazou X-Patchwork-Id: 976409 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-486640-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=adacore.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="i7/QSJqy"; 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 42MHy82f4nz9s1x for ; Sat, 29 Sep 2018 03:01:18 +1000 (AEST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:subject:date:message-id:mime-version:content-type :content-transfer-encoding; q=dns; s=default; b=WIp02TNrA7PKI9cy pC8SPX1vGiclmIPqMuujsUh/P/2Snb+NXG/DKh+0+EQIzElUQTVNUl3yZ0Oys6a8 SMoJuCYlyHt+VTJQDK7HhmHaMDNG63ypacwsiu3yS1WtVIptsMfyYa1QAPWkzgPB qfFZ49slrZToLyEvk94HhZymaN4= 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:from :to:subject:date:message-id:mime-version:content-type :content-transfer-encoding; s=default; bh=ZErTlXTC+3aUvP/WHdMhx5 2ODWA=; b=i7/QSJqyS4J5IIQYykpN7Bs1VxbVwWmmwIq78hKT5azHkfFPDugA6g ObrNGP3XYAMGharmtEyFbTtsgkGyNP/VcdiMPauiYJt5MiXK/2nqpL9+qZrRyt3k LgkrSp1+Br5DPrKdTrKoq9BTkHPeRIg3xfYFViFSxY6T6LNnqVcMg= Received: (qmail 121667 invoked by alias); 28 Sep 2018 17:01:10 -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 121528 invoked by uid 89); 28 Sep 2018 17:00:56 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-9.9 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_2, GIT_PATCH_3, KAM_ASCII_DIVIDERS, KAM_NUMSUBJECT, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy=Hx-languages-length:3356, latent, TREE_OPERAND, tree_operand X-HELO: smtp.eu.adacore.com Received: from mel.act-europe.fr (HELO smtp.eu.adacore.com) (194.98.77.210) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 28 Sep 2018 17:00:52 +0000 Received: from localhost (localhost [127.0.0.1]) by filtered-smtp.eu.adacore.com (Postfix) with ESMTP id 65FC48150F for ; Fri, 28 Sep 2018 19:00:45 +0200 (CEST) Received: from smtp.eu.adacore.com ([127.0.0.1]) by localhost (smtp.eu.adacore.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id k04fRIacWg5b for ; Fri, 28 Sep 2018 19:00:45 +0200 (CEST) Received: from polaris.localnet (bon31-6-88-161-99-133.fbx.proxad.net [88.161.99.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.eu.adacore.com (Postfix) with ESMTPSA id 32CB1814FA for ; Fri, 28 Sep 2018 19:00:44 +0200 (CEST) From: Eric Botcazou To: gcc-patches@gcc.gnu.org Subject: [patch] Fix PR tree-optimization/86659 Date: Fri, 28 Sep 2018 18:59:53 +0200 Message-ID: <2153499.tvKfKlq6V1@polaris> MIME-Version: 1.0 Hi, this is a regression introduced by the canonicalization of BIT_FIELD_REF in match.pd, which totally disregards the REF_REVERSE_STORAGE_ORDER flag, and visible as the failure of gnat.dg/sso/q[23].adb on SPARC 64-bit. But the underlying issue of the missing propagation of the flag during GIMPLE folding has probably been latent for quite some time on all active branches. Tested on x86-64/Linux and SPARC/Solaris, OK for mainline? And branches? 2018-09-28 Eric Botcazou PR tree-optimization/86659 * gimple-match.h (struct gimple_match_op): Add reverse field. (gimple_match_op::set_op): New overloaded method. * gimple-match-head.c (maybe_build_generic_op) : Set the REF_REVERSE_STORAGE_ORDER flag on the value. (gimple_simplify) : For BIT_FIELD_REF, propagate the REF_REVERSE_STORAGE_ORDER flag and avoid simplifying if it is set. Index: gimple-match.h =================================================================== --- gimple-match.h (revision 264686) +++ gimple-match.h (working copy) @@ -98,6 +98,7 @@ struct gimple_match_op void set_op (code_helper, tree, tree); void set_op (code_helper, tree, tree, tree); void set_op (code_helper, tree, tree, tree, tree); + void set_op (code_helper, tree, tree, tree, tree, bool); void set_op (code_helper, tree, tree, tree, tree, tree); void set_op (code_helper, tree, tree, tree, tree, tree, tree); void set_value (tree); @@ -117,6 +118,10 @@ struct gimple_match_op /* The type of the result. */ tree type; + /* For a BIT_FIELD_REF, whether the group of bits is stored in reverse order + from the target order. */ + bool reverse; + /* The number of operands to CODE. */ unsigned int num_ops; @@ -243,6 +248,19 @@ gimple_match_op::set_op (code_helper cod num_ops = 3; ops[0] = op0; ops[1] = op1; + ops[2] = op2; +} + +inline void +gimple_match_op::set_op (code_helper code_in, tree type_in, + tree op0, tree op1, tree op2, bool reverse_in) +{ + code = code_in; + type = type_in; + reverse = reverse_in; + num_ops = 3; + ops[0] = op0; + ops[1] = op1; ops[2] = op2; } Index: gimple-match-head.c =================================================================== --- gimple-match-head.c (revision 264686) +++ gimple-match-head.c (working copy) @@ -445,16 +445,20 @@ void maybe_build_generic_op (gimple_match_op *res_op) { tree_code code = (tree_code) res_op->code; + tree val; switch (code) { case REALPART_EXPR: case IMAGPART_EXPR: case VIEW_CONVERT_EXPR: - res_op->set_value (build1 (code, res_op->type, res_op->ops[0])); + val = build1 (code, res_op->type, res_op->ops[0]); + res_op->set_value (val); break; case BIT_FIELD_REF: - res_op->set_value (build3 (code, res_op->type, res_op->ops[0], - res_op->ops[1], res_op->ops[2])); + val = build3 (code, res_op->type, res_op->ops[0], res_op->ops[1], + res_op->ops[2]); + REF_REVERSE_STORAGE_ORDER (val) = res_op->reverse; + res_op->set_value (val); break; default:; } @@ -853,7 +857,10 @@ gimple_simplify (gimple *stmt, gimple_ma op0 = do_valueize (op0, top_valueize, valueized); res_op->set_op (code, type, op0, TREE_OPERAND (rhs1, 1), - TREE_OPERAND (rhs1, 2)); + TREE_OPERAND (rhs1, 2), + REF_REVERSE_STORAGE_ORDER (rhs1)); + if (res_op->reverse) + return valueized; return (gimple_resimplify3 (seq, res_op, valueize) || valueized); }