From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 106190 invoked by alias); 22 Oct 2016 22:59:36 -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 106171 invoked by uid 89); 22 Oct 2016 22:59:35 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE,SPF_HELO_PASS,SPF_PASS autolearn=ham version=3.3.2 spammy=Individual, H*r:sk:mail-db, HX-HELO:sk:EUR01-D, HTo:D*com.cn X-HELO: EUR01-DB5-obe.outbound.protection.outlook.com Received: from mail-db5eur01on0075.outbound.protection.outlook.com (HELO EUR01-DB5-obe.outbound.protection.outlook.com) (104.47.2.75) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sat, 22 Oct 2016 22:59:25 +0000 Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=cmetcalf@mellanox.com; Received: from [192.168.1.158] (108.20.239.164) by HE1PR0501MB2764.eurprd05.prod.outlook.com (10.172.125.18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.659.11; Sat, 22 Oct 2016 22:59:19 +0000 Subject: Re: [PATCH v3] gcc/config/tilegx/tilegx.c (tilegx_function_profiler): Save r10 to stack before call mcount To: Chen Gang , Jeff Law References: <1465046750-3021-1-git-send-email-chengang@emindsoft.com.cn> <57F6573F.5010003@emindsoft.com.cn> <6cafbf03-21ed-059c-4c4a-e9429ab3ad97@redhat.com> <580A95A6.10308@emindsoft.com.cn> CC: , , , , , Chen Gang From: Chris Metcalf Message-ID: <4dba2a92-359a-052e-f724-ee4a001a60e1@mellanox.com> Date: Sat, 22 Oct 2016 22:59:00 -0000 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.4.0 MIME-Version: 1.0 In-Reply-To: <580A95A6.10308@emindsoft.com.cn> Content-Type: text/plain; charset="utf-8"; format=flowed Content-Transfer-Encoding: 8bit X-ClientProxiedBy: SN2PR17CA0042.namprd17.prod.outlook.com (10.169.188.180) To HE1PR0501MB2764.eurprd05.prod.outlook.com (10.172.125.18) X-MS-Office365-Filtering-Correlation-Id: 750ab4bf-0fe0-4aa1-6b54-08d3facf0fad X-Microsoft-Exchange-Diagnostics: 1;HE1PR0501MB2764;2:lkvJB6SO3tjKUO/rzg6AVQSso6PV7dhxAI0TG9cq5SFucH67UzTDZFtRH/VSj3TfgO7E0QyNMrQVZOCmOUjPJBVSeIAv4/9mUIfhZ8UJ+jdINLcXYTxoKL0Nw9d2MJN3MyMxS6aiLKy30sac0l/AwgsytkqppcKe3nz+8I1tsF4vGCgvDzb6a37IBvYnnvGTwxXzAfGCUyGg26hqvXpGnQ==;3:J2zYs+hc6Yn//QTbGiL7fi++6m7aDPNSd2Dl2V3WjppeK8PvGViTudQKWW0I2GafCAFBJ1EOrLyBB2z4IZAQfvsAuu9TvJsW5lR0jMIN+kwPI39KqNeKGh1pSP0NLTooBnb5hX7WbrjuQsB5oohEEA==;25:H64JRMmjInOUZ6Y9j4LAudVkOJDswh9Zt2zgQJiDICvad2ypNcoW7mcsaOzBA7d+CSSmQUizm19bAnmqnQVISH75mJzqDtkiXrLPGRpMs5YzPbt+WFIXHi0mf1yJ5iiIBUkSR/V4QmaNMPqmZfFcUyktOZhBgWxCpjzwG75nYZTAKF58FsTxo+MhRhaojnipk5Y0F6yC0PW8tQNYMVGA7iZxhi8GqkDDPjDD3on/+gbqoN4Bjbbn0ih6UZsdxcq67aOEIThsqVsk3V+seSI6Xk9vX8o7TNJTX6/cIO3iG3CrTRpuiqJqNnmRXqXQM4IK2g3yeVSA/cwL5FIkY/UyUMSFT0Hae1sIh4+r0r+AiDGRFizKsHy+WWMxRh2r/QWT+bJhqZ221xR3NaGlBN3bvZE0CPEpMcb6bcZoQjrE2unuNxoohXGV3oFqvobNOEWO X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:HE1PR0501MB2764; X-Microsoft-Exchange-Diagnostics: 1;HE1PR0501MB2764;31:Ck8Uh7+7Hcutih7/8iWcPSPJAXge3A0kfMtNAQnG3HBi9vcy/jYXhw35KyZ3cKGurNqFK+hZTNCVq7iOlWcqXJNco+PFJRuDOkJsSnM2DWcYTYVEHjArMchHz/h0UiOAbVYi1qkCTdWShgFwOuNek4Jhl8ufIqTJremnRF08YXBEOdyKf9C6l6qbBVoWQ1JpjFo6CxfyWTRCCIgiGcpoPD842toG/M45OBKSeoTDisp7CekSuFPQ8DpOnBe8f2oD;20:Dk2tnc9D2AmxjIhtsIaDnbw9bTf8XIHne/ixiJP+hgutB6GRgLccxzp0SPIt0yg9cmfIGkUCy0Po+Bv8n7alSWazDTuAaHJeVzk6LriqwpcoLEotRc4Lxfwe2P6dKmVKUVbje74yTMKlJxYFYiFHBZplIj/32o3Jsp1brrjUbKtx8+3xqYJLYZSfNvb6DISWFPFwOV9G9JTTkR1MxdOO5fSU2plHVcGabbOBUEoaSNT4pf5ELm7kBCI4mJRYbBCOX6StQAM0BTvRU03PdLjPL4U8BtMAeQUBsczw5EgrFyJ6uF7RqzT1KmiLPpHtqiAu5t1FnxanB65EFYdnah2LL1IxXww4itsMj11ayWVNHUIE0KMFd2xHsmNT4sSl+sBASqA/IzyzVOB2LfBfv37eCYSGegw2N13g7UJ++8Bff/Ph98swZ7NKyNSbFsv/BF1H2N2uOzS6V4ObdULIz7xe1Lpz/m65bY1baA4vFCoiF9SIl6FFzq9DrNfpmthkaNdI X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(171992500451332); X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(6040176)(601004)(2401047)(8121501046)(5005006)(3002001)(10201501046)(6055026);SRVR:HE1PR0501MB2764;BCL:0;PCL:0;RULEID:;SRVR:HE1PR0501MB2764; X-Microsoft-Exchange-Diagnostics: 1;HE1PR0501MB2764;4:m3RpkttvjVJKHSHfxI8HkeevIYWjEcj1MMMCjECOGyGtSt2VeYCUl/Trsf8jZb9GeoEFyfal0lKZPJrDlAHZ8YBUOFBIPFtCkkmOzoBEdNobSCvaE4I1ekJz6F+l574A0IvtY+KuWGDimhpnfhSd5mkOzBbIXQ4dsxh8JWeKvU/oYqyZMw/hpOlI2tuB2eXTGziq0/MkYe3TBzsU3u/9/EZsL+fczLv/9uEl8YFXVIs+4UKMhlDtpfPrnR0hsiFm8bamNKsh8Rhbc1WRJCBmh1ntBexwZc7NCbmxkImng51bOYjNd3CS5wpl5k3+zHZCQYHuDnNwaXTxHMKXRzvaAfsNX53A2LvgXXIhjWsRx4rkMjyJB2ScdFZIjG64fcCey+HpqqpZRFP2zCZ3hoDVX7vmNTi/T1/a+1gZYSdNQ9s4mBELdLocwu0NZPSVexPEzNE/ky18zB7yZzbaZtzOnQ== X-Forefront-PRVS: 01039C93E4 X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10009020)(4630300001)(6009001)(6049001)(7916002)(377424004)(199003)(189002)(377454003)(24454002)(65826007)(101416001)(83506001)(586003)(50466002)(23676002)(105586002)(106356001)(8676002)(2950100002)(189998001)(33646002)(6666003)(3846002)(47776003)(42186005)(4326007)(65956001)(65806001)(6116002)(2870700001)(81156014)(81166006)(66066001)(93886004)(86362001)(31686004)(77096005)(97736004)(5001770100001)(92566002)(117156001)(64126003)(15975445007)(4001350100001)(68736007)(5660300001)(50986999)(36756003)(76176999)(54356999)(305945005)(7846002)(31696002)(7736002)(2906002)(19580395003)(19580405001)(8666005)(7059030)(18886065003);DIR:OUT;SFP:1101;SCL:1;SRVR:HE1PR0501MB2764;H:[192.168.1.158];FPR:;SPF:None;PTR:InfoNoRecords;A:1;MX:1;LANG:en; Received-SPF: None (protection.outlook.com: mellanox.com does not designate permitted sender hosts) X-Microsoft-Exch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764;7:nbTChgvrP8NcNka8dil0dMOImuM3RR/kcfBQfFsa16q3lPCfHZ8j87YoNrpxi/8zHXLNN/l1pkYrBImacZYMCIpeauBz2bfDQOpzHNFfD3w+3q917nVSYuiKLK/lkvOFnGrBf4GUnmGmv7GYogijRbg4g0IRZuYBAxWYYdDprydPJnHsQcXDBrI63Sm8D3/S3jw5lbXIWpi0UAIbA/TxcaxrDlDNTvGvUqyqe5fZ1It3KjgmHutXjzfrhb/7gdmfGuutvRcH+HHh/tf/MR3/C/AwMHaQfL0Y1BnPFZyIjMfxWu7Pc0+u1sjWw2Z9EIfiUYrPteuDBiuyLRfLuPgfhLC0RGx1GGBkRnwObhHWOkY= X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Oct 2016 22:59:19.5971 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: HE1PR0501MB2764 X-SW-Source: 2016-10/txt/msg01844.txt.bz2 On 10/21/2016 6:24 PM, Chen Gang wrote: > On 10/20/16 06:42, Jeff Law wrote: >>> On 6/4/16 21:25, chengang@emindsoft.com.cn wrote: >>>> From: Chen Gang >>>> >>>> r10 may also be as parameter stack pointer for the nested function, so >>>> need save it before call mcount. >>>> >>>> Also clean up code: use '!' instead of "== 0" for checking >>>> static_chain_decl and compute_total_frame_size. >>>> >>>> 2016-06-04 Chen Gang >>>> >>>> gcc/ >>>> PR target/71331 >>>> * config/tilegx/tilegx.c (tilegx_function_profiler): Save r10 >>>> to stack before call mcount. >>>> (tilegx_can_use_return_insn_p): Clean up code. >> So if I understand the tilegx architecture correctly, you're issuing the r10 save & sp adjustment as a bundle, and the restore & sp adjustment as a bundle. >> >> The problem is the semantics of bunding on the tilegx effectively mean that all source operands are read in parallel, then all outputs occur in parallel. >> >> So if we take the bundle >> >> {addi sp,sp,-8 ; st sp, r10} >> >> The address used for the st is the value of the stack pointer before the addi instruction. >> >> Similarly for the restore r10 bundle. The address used for the load is sp before adjustment. >> >> Given my understanding of the tilegx bundling semantics, that seems wrong. >> >> Jeff >> > > The comments on 1st page of "TILE-Gx Instruction Set Architecture": > > Individual instructions within a bundle must comply with certain register semantics. Read-after-write (RAW) dependencies are enforced between instruction bundles. There is no ordering within a bundle, and the numbering of pipelines or instruction slots within a bundle is only used for convenience and does not imply any ordering. Within an instruction bundle, it is valid to encode an output operand that is the same as an input operand. Because there is explicitly no implied dependency within a bundle, the semantics for this specify that the input operands for all instructions in a bundle are read before any of the output operands are written. > > Write-after-write (WAW) semantics between two bundles are defined as: the latest write over-writes earlier writes. > > Within a bundle, WAW dependencies are forbidden. If more than one instruction in a bundle writes to the same output operand register, unpredictable results for any destination operand within that bundle can occur. Also, implementations are free to signal this case as an illegal instruction. There is one exception to this rule—multiple instructions within a bundle may legally target the zero register. Lastly, some instructions, such as instructions that implicitly write the link register, implicitly write registers. If an instruction implicitly writes to a register that another instruction in the same bundle writes to, unpredictable results can occur for any output register used by that bundle and/or an illegal instruction interrupt can occur. > > On Page 221, ld instruction is: > > ld Dest, Src > > On Page 251, st instruction is: > > st SrcA, SrcB > > > So for me: > > Bundle {addi sp, sp, 8; ld r10, sp} is OK, it is RAW. > > Bundle {addi sp, sp, -8; st sp, r10} is OK, too, it is RAW (not WAW -- > both SrcA and SrcB are input operands). > > > Please help check, if need the related document, please let me know. As you wrote, RAW applies "between instruction bundles". In this case you are looking at register usage within a single bundle, and as you wrote, "the input operands for all instructions in a bundle are read before any of the output operands are written." So for your two bundles quoted above, the "sp" input operand for both instructions will have the same value, i.e. the load/store will have the pre-adjusted "sp" value. -- Chris Metcalf, Mellanox Technologies http://www.mellanox.com