From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pg1-x52e.google.com (mail-pg1-x52e.google.com [IPv6:2607:f8b0:4864:20::52e]) by sourceware.org (Postfix) with ESMTPS id D493B382CE1E for ; Sat, 17 Dec 2022 01:42:25 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org D493B382CE1E Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-pg1-x52e.google.com with SMTP id 79so2881698pgf.11 for ; Fri, 16 Dec 2022 17:42:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=rgvW0iSLFKvNKEGbs3J9ks3XVqhKwvj+o90yc/b53fM=; b=cJRsYV1bQsZOQA4TyB9pDViOBb0Fk/+6JIZqi5ZPeCRS1lvhA+oNkOSZ92rT9cnV2L D475UWILcY6V6I8ou4b6PASEsPIK0FzH38VzLU+8QTVS2fxFV0ebj2uTntkWpmLwJK3g v8oKGt2BysqTymyOUOtDDv611ALSiX8KqllWE1EVS3/WpMYvBaZGIJyMeAqbgJAqeTkv RvHbNNsdJGWtogdUf9s9N3f/yj3r1hIDV3te386oo4NO04PCHHNlF5JWSm9As3U60eBm lz7/ld5yRihVIkERUdFfrdIE8Yi/sb6cmF56Vi9yZnFRxpVkbh0EmPG9BYU6PB/B5+ag dc0g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=rgvW0iSLFKvNKEGbs3J9ks3XVqhKwvj+o90yc/b53fM=; b=rRauNNRqvAW6bhJKVbuzAtqfiq6YBq0sq6p38G8ZHhK3fQej8CzxvhHy/LJn2eUlvC AdvhItAFDW3pfPobUeTa/r2p7dKX1j8uX6TgrWXMl0J5cx5t8exFaNX8IP4glbJVN3au +Yfsms2bRX90jJV+cCQi0bwOPR+fMQ3v5RV9KQOyz7NSbL/s1iRcZOIt0ZGYzswxYT1K mPB2dvHQ0Od+WiWhKu2xzQg5L95CvBbaoN7wPMntK22QuBZpyLVTNYfGi5pgBjFyU+O9 97LBRWTURKlkLUCOeNhLtLwJu74YPFgoHTZF7SRUCruSzxa6s0fOxKIO0/poc3fIIMyM skgw== X-Gm-Message-State: ANoB5pkJko3Cy+5mZTUGuLaQvVW7IOv77WyGYmQozIprVG7A9sSipYba dsBFJgy12GmBvmjr+iUxuAI= X-Google-Smtp-Source: AA0mqf5ahzEWkjhehfbuzXC4yxkmgC4Lqaqurn73wCRXjft/MnVhVgfq18XWZj2tppJsBpyVMP7KAg== X-Received: by 2002:aa7:91d6:0:b0:577:92d1:cc83 with SMTP id z22-20020aa791d6000000b0057792d1cc83mr36133277pfa.14.1671241344643; Fri, 16 Dec 2022 17:42:24 -0800 (PST) Received: from ?IPV6:2601:681:8600:13d0::f0a? ([2601:681:8600:13d0::f0a]) by smtp.gmail.com with ESMTPSA id x128-20020a626386000000b005767cb32fdasm2077287pfb.188.2022.12.16.17.42.23 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 16 Dec 2022 17:42:23 -0800 (PST) Message-ID: <31305c93-d716-f8f2-a061-ccecc62f95b2@gmail.com> Date: Fri, 16 Dec 2022 18:42:22 -0700 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.5.0 Subject: Re: [PATCH] RISC-V: Add testcases for VSETVL PASS Content-Language: en-US To: =?UTF-8?B?6ZKf5bGF5ZOy?= , gcc-patches Cc: "kito.cheng" , palmer References: <20221214080931.192028-1-juzhe.zhong@rivai.ai> <1bcbe6fb-74be-34b4-b178-ffb324abca43@gmail.com> From: Jeff Law In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.9 required=5.0 tests=BAYES_00,BODY_8BITS,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,NICE_REPLY_A,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=ham 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 12/16/22 18:31, 钟居哲 wrote: > Register allocation (RA) doesn't affect the assembler checks since I > relax the registers in assmebler checks, > all assmebler checks have their own goal. For example: > > The code like this: > > +void foo2 (void * restrict in, void * restrict out, int n) > +{ > + for (int i = 0; i < n; i++) > + { > + vuint16mf4_t v = *(vuint16mf4_t*)(in + i); > + *(vuint16mf4_t*)(out + i) = v; > + } > +} > > Assembler check: > > scan-assembler-times {vsetvli\s+(?:ra|[sgtf]p|t[0-6]|s[0-9]|s10|s11|a[0-7]),\s*zero,\s*e16,\s*mf4,\s*t[au],\s*m[au]\s+\.L[0-9]\:\s+vle16\.v\s+(?:v[0-9]|v[1-2][0-9]|v3[0-1]),0\s*\((?:ra|[sgtf]p|t[0-6]|s[0-9]|s10|s11|a[0-7])\ > > I don't care about which vector register is using since I relax register in assembler : (?:v[0-9]|v[1-2][0-9]|v3[0-1]), this means any vector register v0-v31 > > But also I relax scalar register : (?:ra|[sgtf]p|t[0-6]|s[0-9]|s10|s11|a[0-7]), so could be any x0 - x31 of them. > > The only strict check is that make sure the vsetvl is hoist outside the loop meaning the location of vsetvl is outside of the Lable L[0-9]: > > vsetvli\s+(?:ra|[sgtf]p|t[0-6]|s[0-9]|s10|s11|a[0-7]),\s*zero,\s*e16,\s*mf4,\s*t[au],\s*m[au]\s+\.L[0-9] > > You can see the last assembler is \s+\.L[0-9] to make sure VSETVL PASS successfully do the optimization that hoist the vsetvl instruction outside the loop > > I try to use check-function-body but it fails since it can not recognize the Lable which is most important for such cases. Ah, I should have looked at those regexps closer. Understood about the checking for hoisting the vsetvl. Though it makes me wonder if we'd be better off dumping information out of the vsetvl pass. In the case of hoisting we could dump the loop nest of the original evaluation block and the loop nest of the new vsetvl location, then we scan for those in the vsetvl pass dump. While it doesn't check the assembly code, it's probably just as good if not better. Consider that as an alternative. But I'm not going to insist on it. I just know we've had a lot of trouble through the years where assembly code changes slightly, causing test fails. So I try to avoid too much assembly scanning if it can be avoided. Often the easiest way to get the same basic effect is to dump at the transformation point and scan for those markers in the dump file. Jeff