From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 119F53858C54; Sun, 8 May 2022 12:45:41 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 119F53858C54 From: "goswin-v-b at web dot de" To: gcc-bugs@gcc.gnu.org Subject: [Bug target/105521] missed optimization in modulo arithmetic Date: Sun, 08 May 2022 12:45:41 +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: 11.3.0 X-Bugzilla-Keywords: missed-optimization X-Bugzilla-Severity: enhancement X-Bugzilla-Who: goswin-v-b at web dot de X-Bugzilla-Status: NEW 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 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 08 May 2022 12:45:41 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D105521 --- Comment #3 from Goswin von Brederlow --- (In reply to Andrew Pinski from comment #1) > This requires having a, 64bit/32bit (and 128bit/64bit) pattern really. So > this is both a middle-end issue and a target issue. >=20 > Note there might be another bug asking for the same optimization. >=20 > Also note x86_64 might be the only popular target which has this kind of = div > instruction so this might not get any attention as it is also a small > peephole where most people don't use 128bit integers either (they are > non-standard even). I know m68k had a 64bit/32bit pattern but it is indeed rare. On x86_64 a (32bit * 32bit =3D 64bit) % 32bit uses the 128bit/64bit DIV instruction and two extra truncation to 32bit for the input registers. On m= any cpus that is significantly (factor 3-10) slower than the 64bit/32bit versio= n. This could potentially affect every / and % operation and preceding *, allo= wing for the faster opcodes with fewer bits to be used where the compiler can re= ason about the magnitude of the arguments.=