From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id C36FE384601E; Sun, 3 Jan 2021 12:06:23 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C36FE384601E From: "gabravier at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/96930] Failure to optimize out arithmetic with bigger size when it can't matter with division transformed into right shift Date: Sun, 03 Jan 2021 12:06:23 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: tree-optimization X-Bugzilla-Version: 11.0 X-Bugzilla-Keywords: missed-optimization X-Bugzilla-Severity: normal X-Bugzilla-Who: gabravier at gmail dot com 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, 03 Jan 2021 12:06:23 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D96930 --- Comment #6 from Gabriel Ravier --- For this exact code : unsigned f(unsigned a, unsigned b) { return a / (unsigned long long)(1U << b); } compiled with a trunk-based GCC built yesterday for x86-64-linux-gnu config= ured with: ../gcc-trunk-20210102/configure --prefix=3D/opt/compiler-explorer/gcc-build/staging --build=3Dx86_64-linux-= gnu --host=3Dx86_64-linux-gnu --target=3Dx86_64-linux-gnu --disable-bootstrap --enable-multiarch --with-abi=3Dm64 --with-multilib-list=3Dm32,m64,mx32 --enable-multilib --enable-clocale=3Dgnu --enable-languages=3Dc,c++,fortran= ,ada,d --enable-ld=3Dyes --enable-gold=3Dyes --enable-libstdcxx-debug --enable-libstdcxx-time=3Dyes --enable-linker-build-id --enable-lto --enable-plugins --enable-threads=3Dposix --with-pkgversion=3DCompiler-Explorer-Build with the specific compiler command line of `g++ -g -o /tmp/compiler-explorer-compiler202103-4524-15mdddx.f4b4g/output.s -masm=3Di= ntel -S -fdiagnostics-color=3Dalways -O3 /tmp/compiler-explorer-compiler202103-4524-15mdddx.f4b4g/example.cpp`, I ge= t: f(unsigned int, unsigned int): mov eax, edi mov ecx, esi shr rax, cl ret whereas LLVM uses `shr eax, cl` instead. See also https://godbolt.org/z/Gqza7v for the exact setup I used (in case I missed something and you rather avoid having to wait for me to answer).=