From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from esa2.mentor.iphmx.com (esa2.mentor.iphmx.com [68.232.141.98]) by sourceware.org (Postfix) with ESMTPS id E5BAB382BE5E for ; Sun, 20 Nov 2022 00:23:32 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org E5BAB382BE5E Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=codesourcery.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=mentor.com X-IronPort-AV: E=Sophos;i="5.96,178,1665475200"; d="scan'208";a="87624384" Received: from orw-gwy-01-in.mentorg.com ([192.94.38.165]) by esa2.mentor.iphmx.com with ESMTP; 19 Nov 2022 16:23:31 -0800 IronPort-SDR: UrncpgnouGE6DM5hRV/jjj+Hm7G4i1W8Qrz4i4WqsOQHzHySIhE/N3UXDwBwKTxxcmVUS3vLx7 fbXVwNZFb6Yyj9opXvaCARgtDx7G9HVyTDkv1Q8tl0L5y8SEPyYEeYBYwrob4Ju92w+ivPzQMX jEKm+yMeRquSoKQXkusdTgjtHsroEpHTIqBM7W1U9qC5gRzIDisUsImhvbBRdpJa/bV4IVtwHa TAQLzJj5rdh/kAHTbKdNoyQV6r66kaqF8Iez5B3+YwbeVn6YABB965/hl286FTYJ+cDqtMLjkh Xsg= Message-ID: <2d7e0a45-63f2-0532-5413-0012be5ba0eb@codesourcery.com> Date: Sun, 20 Nov 2022 00:23:26 +0000 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.5.0 Subject: Re: [Patch] gcn: Add __builtin_gcn_{get_stack_limit,first_call_this_thread_p} To: Tobias Burnus , gcc-patches References: <1bec26d6-e2c5-3408-4f61-0fb17e730b3e@codesourcery.com> Content-Language: en-GB From: Andrew Stubbs In-Reply-To: Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 8bit X-Originating-IP: [137.202.0.90] X-ClientProxiedBy: svr-ies-mbx-13.mgc.mentorg.com (139.181.222.13) To svr-ies-mbx-11.mgc.mentorg.com (139.181.222.11) X-Spam-Status: No, score=-5.1 required=5.0 tests=BAYES_00,BODY_8BITS,HEADER_FROM_DIFFERENT_DOMAINS,KAM_DMARC_STATUS,NICE_REPLY_A,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS,TXREP autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On 19/11/2022 10:46, Tobias Burnus wrote: > On 18.11.22 18:49, Andrew Stubbs wrote: >> On 18/11/2022 17:20, Tobias Burnus wrote: >> >> This looks wrong: >> >>> +    /* stackbase = (stack_segment_decr & 0x0000ffffffffffff) >>> +            + stack_wave_offset); >>> +       seg_size = dispatch_ptr->private_segment_size; >>> +       stacklimit = stackbase + seg_size*64; > (this should be '*seg_size' not 'seg_size' and the name should be > s/seg_size/seg_size_ptr/.) Yes, looking again I think the comment is misleading, but the code has the MEM so the dereference is there. >>> +       with segsize = dispatch_ptr + 6*sizeof(int16_t) + >>> 3*sizeof(int32_t); >>> +       cf. struct hsa_kernel_dispatch_packet_s in the HSA doc. */ >>> +    rtx ptr; >>> +    if (cfun->machine->args.reg[DISPATCH_PTR_ARG] >= 0 >>> +        && cfun->machine->args.reg[PRIVATE_SEGMENT_BUFFER_ARG] >= 0) >>> +      { >>> +        rtx size_rtx = gen_rtx_REG (DImode, >>> + cfun->machine->args.reg[DISPATCH_PTR_ARG]); >>> +        size_rtx = gen_rtx_MEM (DImode, >>> +                    gen_rtx_PLUS (DImode, size_rtx, >>> +                          GEN_INT (6*16 + 3*32))); >>> +        size_rtx = gen_rtx_MULT (DImode, size_rtx, GEN_INT (64)); >>> + > (Reading it, I think it should be '..._MEM(SImode,' and > '..._MULT(SImode' instead of DImode.) Yes, I think you're right; the field is uint32. > Admittedly, there is probably something not quite right as I see with > gfx908 > >   # of expected passes            27476 >   # of unexpected failures        317 > > where 317 FAIL comes from 88 testcase files. > > That's not a a very high number but more than the usual fails, which > shows that > something is not quite right. > >  * * * > > I am pretty sure that I missed something - but the question is what. > I hope you can help me pinpoint the place where it goes wrong. This might be it: > + if (cfun->machine->args.reg[PRIVATE_SEGMENT_WAVE_OFFSET_ARG] >= 0) > + { > + rtx off; > + off = gen_rtx_REG (SImode, > + cfun->machine->args.reg[PRIVATE_SEGMENT_WAVE_OFFSET_ARG]); > + ptr = gen_rtx_PLUS (DImode, ptr, off); > + } I think "off" needs to be zero-extended before you can add the SImode to DImode (same for the segment size, of course). Andrew