From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 7EBD83858D37; Thu, 1 Feb 2024 01:59:35 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 7EBD83858D37 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1706752775; bh=XGesMFlwEtm5+sZFOntvvFunrit+haqs4/nRra8Bmh0=; h=From:To:Subject:Date:From; b=Je0rQzOGq8kSLk7XT5KebC0l8nYeZ34c7gxQCO6xM+BDGqZ1beetXRmLVbWn5b3L3 HcXhg2lPLmFGtMOcaw3B/q/Fwo264Z7jyYQdm18w0gTK8R/srjRCLJUjfqMHxn3e2q wnX5TfNJBSqBmJcj171AiNo6uun7yPAYPvD2q8Ls= From: "pan2.li at intel dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug c/113697] New: RISC-V: Redundant vsetvl insn in function Date: Thu, 01 Feb 2024 01:59:35 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c X-Bugzilla-Version: 14.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: pan2.li at intel dot com X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D113697 Bug ID: 113697 Summary: RISC-V: Redundant vsetvl insn in function Product: gcc Version: 14.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: pan2.li at intel dot com Target Milestone: --- Give the sample code as below, build with -march=3Drv64gcv -O3 -g0 int foo (int * __restrict a, int n) { int result =3D 0; for (int i =3D 0; i < n; i++) result +=3D a[i]; return result; } The asm code looks like below, we have one duplicated vsetvl insn here. foo: .LFB0: .cfi_startproc ble a1,zero,.L4 vsetvli a5,zero,e32,m1,ta,ma vmv.v.i v1,0 .L3: vsetvli a5,a1,e32,m1,tu,ma slli a4,a5,2 sub a1,a1,a5 vle32.v v2,0(a0) add a0,a0,a4 vadd.vv v1,v2,v1 bne a1,zero,.L3 li a5,0 vsetivli zero,1,e32,m1,ta,ma vmv.s.x v2,a5 vsetvli a5,zero,e32,m1,ta,ma <=3D=3D redundant vsetvl vredsum.vs v1,v1,v2 vmv.x.s a0,v1 ret .L4: li a0,0 ret=