From patchwork Sun Jun 3 11:47:38 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Botcazou X-Patchwork-Id: 924713 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-478975-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="dm4jr8fM"; 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 40zGdf0hY2z9s0x for ; Sun, 3 Jun 2018 21:52:19 +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=XtK/r6zwf0HqXfQC g0ktEf79HgUXSgw9qoXGqzR2OFTUEJvZ+fSOOGMS/Bkt7UonJZlz9GmII2ySWejE undkCxJnJe8XdrIxGyi5Dx1LnwzSvy9u4XTtAHuLdZCM8eBo4q1gxyv+InyBAfS3 5b7uiip0gNZge2kgQKKLluQDRZo= 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=mA/UC08Fme3HZZ91qrrmUL 7UOo4=; b=dm4jr8fMLGRCbeRx63Ek1AMYv3+qXvKEBC4KiaXjRctZTEjfRXWXrI xRaeSqzYu52t53ULz6hqTq23OenNepqTlknmAN+K3SS6PyWJyqTLypx1yNBpOMQm +/Q+M0s6Ua16hw9EEzpp0svA8caLVhH8YXohxDzsygmSr6a3zLt38= Received: (qmail 60587 invoked by alias); 3 Jun 2018 11:52:11 -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 60576 invoked by uid 89); 3 Jun 2018 11:52:11 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-10.6 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_2, GIT_PATCH_3, KAM_NUMSUBJECT, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy=whereby, rhs_code, rhs1, SSA_NAME 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; Sun, 03 Jun 2018 11:52:09 +0000 Received: from localhost (localhost [127.0.0.1]) by filtered-smtp.eu.adacore.com (Postfix) with ESMTP id 13CC98138A for ; Sun, 3 Jun 2018 13:52:07 +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 jt_Baoo-59DF for ; Sun, 3 Jun 2018 13:52:07 +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 E6C0B81388 for ; Sun, 3 Jun 2018 13:52:06 +0200 (CEST) From: Eric Botcazou To: gcc-patches@gcc.gnu.org Subject: Fix PR tree-optimization/86034 Date: Sun, 03 Jun 2018 13:47:38 +0200 Message-ID: <14983703.7c19u95Jvh@polaris> MIME-Version: 1.0 This fixes an oversight in my GIMPLE store-merging patch, whereby masking out the bits of a signed type obviously fails to turn it into an unsigned type... And since output_merged_store will now convert to the unsigned bitfield type, an existing conversion from a smaller type can be bypassed in process_store. Tested on x86-64/Linux, applied on the mainline as obvious. 2018-06-03 Eric Botcazou PR tree-optimization/86034 * gimple-ssa-store-merging.c (output_merged_store): Convert the RHS to the unsigned bitfield type in a bit insertion sequence if it does not have a larger precision than the bitfield size. (process_store): Also bypass widening conversions for BIT_INSERT_EXPR. 2018-06-03 Eric Botcazou * gcc.dg/torture/pr86034.c: New test. Index: gimple-ssa-store-merging.c =================================================================== --- gimple-ssa-store-merging.c (revision 261101) +++ gimple-ssa-store-merging.c (working copy) @@ -3778,7 +3778,14 @@ imm_store_chain_info::output_merged_stor const HOST_WIDE_INT end_gap = (try_bitpos + try_size) - (info->bitpos + info->bitsize); tree tem = info->ops[0].val; - if ((BYTES_BIG_ENDIAN ? start_gap : end_gap) > 0) + if (TYPE_PRECISION (TREE_TYPE (tem)) <= info->bitsize) + { + tree bitfield_type + = build_nonstandard_integer_type (info->bitsize, + UNSIGNED); + tem = gimple_convert (&seq, loc, bitfield_type, tem); + } + else if ((BYTES_BIG_ENDIAN ? start_gap : end_gap) > 0) { const unsigned HOST_WIDE_INT imask = (HOST_WIDE_INT_1U << info->bitsize) - 1; @@ -4270,13 +4277,12 @@ pass_store_merging::process_store (gimpl || !multiple_p (bitpos, BITS_PER_UNIT)) && const_bitsize <= 64) { - /* Bypass a truncating conversion to the bit-field type. */ + /* Bypass a conversion to the bit-field type. */ if (is_gimple_assign (def_stmt) && CONVERT_EXPR_CODE_P (rhs_code)) { tree rhs1 = gimple_assign_rhs1 (def_stmt); if (TREE_CODE (rhs1) == SSA_NAME - && INTEGRAL_TYPE_P (TREE_TYPE (rhs1)) - && const_bitsize <= TYPE_PRECISION (TREE_TYPE (rhs1))) + && INTEGRAL_TYPE_P (TREE_TYPE (rhs1))) rhs = rhs1; } rhs_code = BIT_INSERT_EXPR;