From patchwork Fri Oct 7 14:08:36 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kyrill Tkachov X-Patchwork-Id: 679277 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]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3srBG427hXz9t1j for ; Sat, 8 Oct 2016 01:09:00 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=x6q0fOW/; dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :message-id:date:from:mime-version:to:subject:content-type; q= dns; s=default; b=lvYsFPmxRewCi2VM2bGAKs8Xr5ZieymjFmKK3TQQC/wLOW iiEXljnngc3v1GUZB7bSWvt35351gu1pUafRph7zEUJzn1fBm2wU5c2DVIdVWV3M SSo2GhkbFtHE/iEuX2TVsM9u2RLw7mEoqezkDUfozaiAzZZriKTicuXc5liUU= 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 :message-id:date:from:mime-version:to:subject:content-type; s= default; bh=E2yF0AUTQXDbZCYcpXm2K/9Me8M=; b=x6q0fOW/YOM1Yh0GgYYg m1wyPeL3ezSQlYE3H3i41zNlXuOOWHafH3rK8+BkytZDfYVT4CRB1N/51soa+45H q/yzcj1crRRTP30ZmWxNOaWw5dax7YkhdVR3qNdbm/PN+oOgU6wU4f2WR9XR8hkW juM7KmqHrVY0RZEkZULg65A= Received: (qmail 86305 invoked by alias); 7 Oct 2016 14:08:52 -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 85075 invoked by uid 89); 7 Oct 2016 14:08:51 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.6 required=5.0 tests=BAYES_00, KAM_LAZY_DOMAIN_SECURITY, RP_MATCHES_RCVD autolearn=ham version=3.3.2 spammy=sk:kyrylo, U*kyrylo.tkachov, sk:kyrylo. X-HELO: foss.arm.com Received: from foss.arm.com (HELO foss.arm.com) (217.140.101.70) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 07 Oct 2016 14:08:41 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id AB2EE29 for ; Fri, 7 Oct 2016 07:08:38 -0700 (PDT) Received: from [10.2.207.77] (e100706-lin.cambridge.arm.com [10.2.207.77]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 5717A3F32C for ; Fri, 7 Oct 2016 07:08:38 -0700 (PDT) Message-ID: <57F7AC64.900@foss.arm.com> Date: Fri, 07 Oct 2016 15:08:36 +0100 From: Kyrill Tkachov User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.2.0 MIME-Version: 1.0 To: GCC Patches Subject: [PATCH][simplify-rtx] Zero-initialise local array in simplify_immed_subreg Hi all, I've encountered another wrong-code bug with the store merging pass. This time it's in RTL. The test gcc.target/aarch64/aapcs64/test_27.c on aarch64 merges a few __fp16 values at GIMPLE level but during RTL dse1 one of the constants generated gets wrongly misinterpreted from HImode to HFmode by simplify_immed_subreg. The HFmode value it ends up producing is completely bogus. By stepping through the code with GDB the problem is in the hunk touched by this patch when it fills in an array of longs with the value bytes before passing it down to real_from_target. It fills in the array by orring in each byte. However, the array it declared to use for this doesn not get properly zero-initialised for modes less that 32 bits wide (HFmode in this case). The fix in this patch is to just use an array initialiser to zero it out. This makes the failure go away. Bootstrapped and tested on aarch64, x86_64. Ok for trunk? Thanks, Kyrill 2016-10-06 Kyrylo Tkachov * simplify-rtx.c (simplify_immed_subreg): Zero-initialize tmp array before merging in bytes to pass down to real_from_target. diff --git a/gcc/simplify-rtx.c b/gcc/simplify-rtx.c index 4bb16f896f89b06612e923a0b8db8e074b8a734c..9e7376c9f2b967d96b3195a6d9de57a543644d10 100644 --- a/gcc/simplify-rtx.c +++ b/gcc/simplify-rtx.c @@ -5906,14 +5906,12 @@ simplify_immed_subreg (machine_mode outermode, rtx op, case MODE_DECIMAL_FLOAT: { REAL_VALUE_TYPE r; - long tmp[MAX_BITSIZE_MODE_ANY_MODE / 32]; + long tmp[MAX_BITSIZE_MODE_ANY_MODE / 32] = { 0 }; /* real_from_target wants its input in words affected by FLOAT_WORDS_BIG_ENDIAN. However, we ignore this, and use WORDS_BIG_ENDIAN instead; see the documentation of SUBREG in rtl.texi. */ - for (i = 0; i < max_bitsize / 32; i++) - tmp[i] = 0; for (i = 0; i < elem_bitsize; i += value_bit) { int ibase;