From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 86909 invoked by alias); 4 May 2015 10:26:52 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 86897 invoked by uid 89); 4 May 2015 10:26:52 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.4 required=5.0 tests=AWL,BAYES_00,SPF_PASS autolearn=ham version=3.3.2 X-HELO: szxga03-in.huawei.com Received: from Unknown (HELO szxga03-in.huawei.com) (119.145.14.66) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (DES-CBC3-SHA encrypted) ESMTPS; Mon, 04 May 2015 10:26:50 +0000 Received: from 172.24.2.119 (EHLO szxeml432-hub.china.huawei.com) ([172.24.2.119]) by szxrg03-dlp.huawei.com (MOS 4.4.3-GA FastPath queued) with ESMTP id BFM39023; Mon, 04 May 2015 18:26:39 +0800 (CST) Received: from [127.0.0.1] (10.177.16.72) by szxeml432-hub.china.huawei.com (10.82.67.209) with Microsoft SMTP Server id 14.3.158.1; Mon, 4 May 2015 17:13:39 +0800 Message-ID: <55473842.3060606@huawei.com> Date: Mon, 04 May 2015 10:26:00 -0000 From: Chen Shanyao User-Agent: Mozilla/5.0 (Windows NT 6.1; rv:31.0) Gecko/20100101 Thunderbird/31.0 MIME-Version: 1.0 To: "gcc-patches@gcc.gnu.org" , CC: , "Yangfei (Felix)" Subject: [PATCH, AArch64] [4.9] Backport PR64304 fix (miscompilation with -mgeneral-regs-only ) References: <5513D05B.2020909@huawei.com> <5527824C.4090409@huawei.com> <554735D9.8090805@huawei.com> In-Reply-To: <554735D9.8090805@huawei.com> Content-Type: multipart/mixed; boundary="------------000104000009070404080905" X-CFilter-Loop: Reflected X-Mirapoint-Virus-RAPID-Raw: score=unknown(0), refid=str=0001.0A020204.55474960.0092,ss=1,re=0.000,recu=0.000,reip=0.000,cl=1,cld=1,fgs=0, ip=0.0.0.0, so=2013-05-26 15:14:31, dmn=2013-03-21 17:37:32 X-Mirapoint-Loop-Id: 53a32355bda07c8fad28f16b6f561d78 X-SW-Source: 2015-05/txt/msg00206.txt.bz2 --------------000104000009070404080905 Content-Type: text/plain; charset="gb18030"; format=flowed Content-Transfer-Encoding: 7bit Content-length: 3266 According to your opinion, I split the backports of pr64304 into 2 emails, and this one is for 4.9 branch. This patch backport the fix of PR target/64304 , miscompilation with -mgeneral-regs-only, to the 4.9 branch from trunk r219844. Tested on x86_64 by using qemu of aarch64. OK for 4.9? diff -rupN gcc-4.9-20150225/gcc/ChangeLog gcc-4.9-20150225.pr64304//gcc/ChangeLog --- gcc-4.9-20150225/gcc/ChangeLog 2015-03-04 20:48:30.000000000 -0500 +++ gcc-4.9-20150225.pr64304//gcc/ChangeLog 2015-03-04 20:55:59.000000000 -0500 @@ -1,3 +1,13 @@ +2015-03-05 Shanyao Chen + + Backported from mainline + 2015-01-19 Jiong Wang + Andrew Pinski + + PR target/64304 + * config/aarch64/aarch64.md (define_insn "*ashl3_insn"): Deleted. + (ashl3): Don't expand if operands[2] is not constant. + 2015-02-25 Kai Tietz PR tree-optimization/61917 diff -rupN gcc-4.9-20150225/gcc/config/aarch64/aarch64.md gcc-4.9-20150225.pr64304//gcc/config/aarch64/aarch64.md --- gcc-4.9-20150225/gcc/config/aarch64/aarch64.md 2015-03-04 20:41:03.000000000 -0500 +++ gcc-4.9-20150225.pr64304//gcc/config/aarch64/aarch64.md 2015-03-04 20:46:44.000000000 -0500 @@ -2719,6 +2719,8 @@ DONE; } } + else + FAIL; } ) @@ -2947,15 +2949,6 @@ [(set_attr "type" "shift_reg")] ) -(define_insn "*ashl3_insn" - [(set (match_operand:SHORT 0 "register_operand" "=r") - (ashift:SHORT (match_operand:SHORT 1 "register_operand" "r") - (match_operand:QI 2 "aarch64_reg_or_shift_imm_si" "rUss")))] - "" - "lsl\\t%0, %1, %2" - [(set_attr "type" "shift_reg")] -) - (define_insn "*3_insn" [(set (match_operand:SHORT 0 "register_operand" "=r") (ASHIFT:SHORT (match_operand:SHORT 1 "register_operand" "r") diff -rupN gcc-4.9-20150225/gcc/testsuite/ChangeLog gcc-4.9-20150225.pr64304//gcc/testsuite/ChangeLog --- gcc-4.9-20150225/gcc/testsuite/ChangeLog 2015-03-04 21:00:24.000000000 -0500 +++ gcc-4.9-20150225.pr64304//gcc/testsuite/ChangeLog 2015-03-04 21:03:21.000000000 -0500 @@ -1,3 +1,10 @@ +2015-03-05 Shanyao chen + + Backported from mainline + 2015-01-19 Jiong Wang + + * gcc.target/aarch64/pr64304.c: New testcase. + 2015-02-25 Kai Tietz Backported from mainline diff -rupN gcc-4.9-20150225/gcc/testsuite/gcc.target/aarch64/pr64304.c gcc-4.9-20150225.pr64304//gcc/testsuite/gcc.target/aarch64/pr64304.c --- gcc-4.9-20150225/gcc/testsuite/gcc.target/aarch64/pr64304.c 1969-12-31 19:00:00.000000000 -0500 +++ gcc-4.9-20150225.pr64304//gcc/testsuite/gcc.target/aarch64/pr64304.c 2015-03-04 20:59:24.000000000 -0500 @@ -0,0 +1,18 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 --save-temps" } */ + +unsigned char byte = 0; + +void +set_bit (unsigned int bit, unsigned char value) +{ + unsigned char mask = (unsigned char) (1 << (bit & 7)); + + if (! value) + byte &= (unsigned char)~mask; + else + byte |= mask; + /* { dg-final { scan-assembler "and\tw\[0-9\]+, w\[0-9\]+, 7" } } */ +} + +/* { dg-final { cleanup-saved-temps } } */ --------------000104000009070404080905 Content-Type: text/plain; charset="gb18030"; name="pr64304-backport-4.9.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="pr64304-backport-4.9.patch" Content-length: 2904 diff -rupN gcc-4.9-20150225/gcc/ChangeLog gcc-4.9-20150225.pr64304//gcc/ChangeLog --- gcc-4.9-20150225/gcc/ChangeLog 2015-03-04 20:48:30.000000000 -0500 +++ gcc-4.9-20150225.pr64304//gcc/ChangeLog 2015-03-04 20:55:59.000000000 -0500 @@ -1,3 +1,13 @@ +2015-03-05 Shanyao Chen + + Backported from mainline + 2015-01-19 Jiong Wang + Andrew Pinski + + PR target/64304 + * config/aarch64/aarch64.md (define_insn "*ashl3_insn"): Deleted. + (ashl3): Don't expand if operands[2] is not constant. + 2015-02-25 Kai Tietz PR tree-optimization/61917 diff -rupN gcc-4.9-20150225/gcc/config/aarch64/aarch64.md gcc-4.9-20150225.pr64304//gcc/config/aarch64/aarch64.md --- gcc-4.9-20150225/gcc/config/aarch64/aarch64.md 2015-03-04 20:41:03.000000000 -0500 +++ gcc-4.9-20150225.pr64304//gcc/config/aarch64/aarch64.md 2015-03-04 20:46:44.000000000 -0500 @@ -2719,6 +2719,8 @@ DONE; } } + else + FAIL; } ) @@ -2947,15 +2949,6 @@ [(set_attr "type" "shift_reg")] ) -(define_insn "*ashl3_insn" - [(set (match_operand:SHORT 0 "register_operand" "=r") - (ashift:SHORT (match_operand:SHORT 1 "register_operand" "r") - (match_operand:QI 2 "aarch64_reg_or_shift_imm_si" "rUss")))] - "" - "lsl\\t%0, %1, %2" - [(set_attr "type" "shift_reg")] -) - (define_insn "*3_insn" [(set (match_operand:SHORT 0 "register_operand" "=r") (ASHIFT:SHORT (match_operand:SHORT 1 "register_operand" "r") diff -rupN gcc-4.9-20150225/gcc/testsuite/ChangeLog gcc-4.9-20150225.pr64304//gcc/testsuite/ChangeLog --- gcc-4.9-20150225/gcc/testsuite/ChangeLog 2015-03-04 21:00:24.000000000 -0500 +++ gcc-4.9-20150225.pr64304//gcc/testsuite/ChangeLog 2015-03-04 21:03:21.000000000 -0500 @@ -1,3 +1,10 @@ +2015-03-05 Shanyao chen + + Backported from mainline + 2015-01-19 Jiong Wang + + * gcc.target/aarch64/pr64304.c: New testcase. + 2015-02-25 Kai Tietz Backported from mainline diff -rupN gcc-4.9-20150225/gcc/testsuite/gcc.target/aarch64/pr64304.c gcc-4.9-20150225.pr64304//gcc/testsuite/gcc.target/aarch64/pr64304.c --- gcc-4.9-20150225/gcc/testsuite/gcc.target/aarch64/pr64304.c 1969-12-31 19:00:00.000000000 -0500 +++ gcc-4.9-20150225.pr64304//gcc/testsuite/gcc.target/aarch64/pr64304.c 2015-03-04 20:59:24.000000000 -0500 @@ -0,0 +1,18 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 --save-temps" } */ + +unsigned char byte = 0; + +void +set_bit (unsigned int bit, unsigned char value) +{ + unsigned char mask = (unsigned char) (1 << (bit & 7)); + + if (! value) + byte &= (unsigned char)~mask; + else + byte |= mask; + /* { dg-final { scan-assembler "and\tw\[0-9\]+, w\[0-9\]+, 7" } } */ +} + +/* { dg-final { cleanup-saved-temps } } */ --------------000104000009070404080905--