From patchwork Mon Sep 7 03:00:06 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kugan Vivekanandarajah X-Patchwork-Id: 53205 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-lb0-f197.google.com (mail-lb0-f197.google.com [209.85.217.197]) by patches.linaro.org (Postfix) with ESMTPS id E130022B05 for ; Mon, 7 Sep 2015 03:00:48 +0000 (UTC) Received: by lbbti1 with SMTP id ti1sf21339873lbb.3 for ; Sun, 06 Sep 2015 20:00:47 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:mailing-list:precedence:list-id :list-unsubscribe:list-archive:list-post:list-help:sender :delivered-to:subject:to:references:cc:from:message-id:date :user-agent:mime-version:in-reply-to:content-type:x-original-sender :x-original-authentication-results; bh=UMxkYX1z21V5brRPFznWD/vq5QqSIT6564RUpQPoOJ0=; b=VgxDvv/g9FZnSLtOrHgdVuC6GvwD+GosPu4jaDnH4eQjstrt7dFlCZkAmI8ZPB0iIP xh1cN3HhCv5sSpEoWh6jpBnfM2LRzW6ZpYdkgd1JgZmpW66+2VP1KxIc7cnwMkRiKUEh 7zZ9vbtrjA+l/t7jLIdjMvcIULOT1eedNQv3pUouXjT8tBnZByyTW3l/46DaALTibeyF 7ZB2fqPLUcVaIDiKgnvuni1k67ndyLm59VxoVQYHMKwF3ICnKzD+U7NbRRz1yoh/D5Sr heLNU0PVflJVenxwK9U9yZCdidBP+7c6prA2101QVGtGTs7fNuTEX5EBZUURZQF5gANR Ww9A== X-Gm-Message-State: ALoCoQl0vY3qP4Cx7NhahPmhoV5V0KcHP6ANB5pDoUaz3P3Z29NNK5AeEfBq5qptwpggHd4be+Mf X-Received: by 10.180.100.71 with SMTP id ew7mr4401431wib.0.1441594847414; Sun, 06 Sep 2015 20:00:47 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.36.6 with SMTP id m6ls621391laj.32.gmail; Sun, 06 Sep 2015 20:00:47 -0700 (PDT) X-Received: by 10.153.7.137 with SMTP id dc9mr14751724lad.16.1441594846975; Sun, 06 Sep 2015 20:00:46 -0700 (PDT) Received: from mail-la0-x236.google.com (mail-la0-x236.google.com. [2a00:1450:4010:c03::236]) by mx.google.com with ESMTPS id 7si9245931lak.53.2015.09.06.20.00.46 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 06 Sep 2015 20:00:46 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 2a00:1450:4010:c03::236 as permitted sender) client-ip=2a00:1450:4010:c03::236; Received: by lamp12 with SMTP id p12so42950443lam.0 for ; Sun, 06 Sep 2015 20:00:46 -0700 (PDT) X-Received: by 10.152.22.133 with SMTP id d5mr14950358laf.112.1441594846706; Sun, 06 Sep 2015 20:00:46 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.59.35 with SMTP id w3csp119955lbq; Sun, 6 Sep 2015 20:00:45 -0700 (PDT) X-Received: by 10.50.45.41 with SMTP id j9mr211463igm.4.1441594845454; Sun, 06 Sep 2015 20:00:45 -0700 (PDT) Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id dq7si17623940pdb.96.2015.09.06.20.00.44 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 06 Sep 2015 20:00:45 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-return-406779-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Received: (qmail 80893 invoked by alias); 7 Sep 2015 03:00:28 -0000 Mailing-List: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org Precedence: list 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 80540 invoked by uid 89); 7 Sep 2015 03:00:16 -0000 X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.4 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-pa0-f41.google.com Received: from mail-pa0-f41.google.com (HELO mail-pa0-f41.google.com) (209.85.220.41) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Mon, 07 Sep 2015 03:00:15 +0000 Received: by pacej10 with SMTP id ej10so794880pac.3 for ; Sun, 06 Sep 2015 20:00:13 -0700 (PDT) X-Received: by 10.66.145.74 with SMTP id ss10mr40929822pab.28.1441594813782; Sun, 06 Sep 2015 20:00:13 -0700 (PDT) Received: from [10.1.1.7] (58-6-183-210.dyn.iinet.net.au. [58.6.183.210]) by smtp.googlemail.com with ESMTPSA id v2sm9995612pdf.54.2015.09.06.20.00.11 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 06 Sep 2015 20:00:13 -0700 (PDT) Subject: [4/7] Use correct promoted mode sign for result of GIMPLE_CALL To: "gcc-patches@gcc.gnu.org" References: <55ECFC2A.7050908@linaro.org> Cc: Richard Biener From: Kugan Message-ID: <55ECFDB6.8010100@linaro.org> Date: Mon, 7 Sep 2015 13:00:06 +1000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 In-Reply-To: <55ECFC2A.7050908@linaro.org> X-IsSubscribed: yes X-Original-Sender: kugan.vivekanandarajah@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 2a00:1450:4010:c03::236 as permitted sender) smtp.mailfrom=patch+caf_=patchwork-forward=linaro.org@linaro.org; dkim=pass header.i=@gcc.gnu.org X-Google-Group-Id: 836684582541 For the following testcase (compiling with -O1; -O2 works fine), we have a stmt with stm_code SSA_NAME (_7 = _ 6) and for which _6 is defined by a GIMPLE_CALL. In this case, we are using wrong SUNREG promoted mode resulting in wrong code. Simple SSA_NAME copes are generally optimized but when they are not, we can end up using the wrong promoted mode. Attached patch fixes when we have one copy. I think it might be better to do this in a while loop but I don't think it can happen in practice. Please let me know what you think. _6 = bar5 (-10); ... _7 = _6; _3 = (long unsigned int) _6; ... if (_3 != l5.0_4) for extern void abort (void); __attribute__ ((noinline)) static unsigned short int foo5 (int x) { return x; } __attribute__ ((noinline)) short int bar5 (int x) { return foo5 (x + 6); } unsigned long l5 = (short int) -4; int main (void) { if (bar5 (-10) != l5) abort (); return 0; } gcc/ChangeLog: 2015-09-07 Kugan Vivekanandarajah * expr.c (expand_expr_real_1): Set proper SUNREG_PROMOTED_MODE for SSA_NAME that was set by GIMPLE_CALL and assigned to another SSA_NAME of same type. >From 64ac68bfda1d3e8487827512e6d163b384e8a1cf Mon Sep 17 00:00:00 2001 From: Kugan Vivekanandarajah Date: Wed, 2 Sep 2015 12:18:41 +1000 Subject: [PATCH 4/8] use correct promoted sign for result of GIMPLE_CALL --- gcc/expr.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/gcc/expr.c b/gcc/expr.c index bcd87c0..6dac3cf 100644 --- a/gcc/expr.c +++ b/gcc/expr.c @@ -9633,7 +9633,22 @@ expand_expr_real_1 (tree exp, rtx target, machine_mode tmode, gimple_call_fntype (g), 2); else - pmode = promote_ssa_mode (ssa_name, &unsignedp); + { + tree rhs; + gimple stmt; + if (code == SSA_NAME + && is_gimple_assign (g) + && (rhs = gimple_assign_rhs1 (g)) + && TREE_CODE (rhs) == SSA_NAME + && (stmt = SSA_NAME_DEF_STMT (rhs)) + && gimple_code (stmt) == GIMPLE_CALL + && !gimple_call_internal_p (stmt)) + pmode = promote_function_mode (type, mode, &unsignedp, + gimple_call_fntype (stmt), + 2); + else + pmode = promote_ssa_mode (ssa_name, &unsignedp); + } gcc_assert (GET_MODE (decl_rtl) == pmode); temp = gen_lowpart_SUBREG (mode, decl_rtl); -- 1.9.1