From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 642D43858415; Wed, 8 Nov 2023 07:25:59 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 642D43858415 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1699428359; bh=uZ2cGGagQ31AYk9iHdk+iq7z0svnn3a7LdeJftAx1Lg=; h=From:To:Subject:Date:In-Reply-To:References:From; b=qjGqRuUFMD6FkKm1lYLkuUJvdcbFOBI8zKzoCNInJ1rtG18/ZhxqYoAK2NYCexF/q 3Vr06gzr9q5IIhFwBVrg6H6x3A1AHLfWuJACljuGrO4GenBc9XY46MYrhgwa7201gV Nf1STQtjo8S+8fVCkX6TLJjH9nhnPUvJ1KruQnAA= From: "juzhe.zhong at rivai dot ai" To: gcc-bugs@gcc.gnu.org Subject: [Bug target/112438] RISC-V: Failed to AVL propagation through induction variable Date: Wed, 08 Nov 2023 07:25:59 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: target X-Bugzilla-Version: 14.0 X-Bugzilla-Keywords: missed-optimization X-Bugzilla-Severity: normal X-Bugzilla-Who: juzhe.zhong at rivai dot ai 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: Message-ID: In-Reply-To: References: 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=3D112438 --- Comment #4 from JuzheZhong --- Oh. I see what you mean. I think it may not be the valid optimization. Since the following codes: .L3: vsetvli a5,a0,e32,m1,ta,ma slli a4,a5,2 vle32.v v1,0(a1) sub a0,a0,a5 vadd.vv v1,v1,v2 vse32.v v1,0(a2) add a1,a1,a4 vsetvli a5,zero,e32,m1,ta,ma --- > seems redundant add a2,a2,a4 vadd.vv v2,v2,v4 bne a0,zero,.L3 Suppose the VLEN =3D 8 elments. a0 is 13 in the last 2 iterations. If we remove the VLMAX vsetvl which seems redundant. We may have issues in some hardware. Since 13 elements, we can choose to process 6 elements int last second, and 7 elements in the last iteration. The VLMAX vadd.vv result is used by next iteration NOT the current iteratio= n. Then, the vadd.vv will generate 6 elements to the last iteration which need= 7=20 elements. Then it will cause a bug. So, it is not invalid optimization...=