From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 66D7E3858D1E; Mon, 3 Jul 2023 11:17:24 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 66D7E3858D1E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1688383044; bh=2UEcXGuP2qlRwigOZv51GGKh9dbbGJBUQ//X9kGlSxk=; h=From:To:Subject:Date:From; b=JWn5kGUvlmRnc3lY+Bx194xhfcd382uo1XH4xmARdM2hCR6Nv0j8wXnlLEfVmMg75 EET+bPSRIHnJcRpOOtUIdV/5riJPTyNCvmvMvb8JWIk47FDaH5kVLyQBGRlgYNHwau xYGIAKvKqxJt7o6XkuRUSZ7QwBRpdxX7GfpDQE9g= From: "jwzeng at nuaa dot edu.cn" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/110532] New: [14 Regression] Different results between -O0 and -O1 Date: Mon, 03 Jul 2023 11:17:24 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: tree-optimization X-Bugzilla-Version: 14.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: jwzeng at nuaa dot edu.cn 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=3D110532 Bug ID: 110532 Summary: [14 Regression] Different results between -O0 and -O1 Product: gcc Version: 14.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: jwzeng at nuaa dot edu.cn Target Milestone: --- Compiler Explorer: https://godbolt.org/z/xE1K6zKbs The following code snippet: #include unsigned char res, a[25], b[25]; #define max(a, b) ((a) > (b) ? (a) : (b)) #define min(a, b) ((a) < (b) ? (a) : (b)) int main() { for (int i =3D 0; i < 25; ++i) a[i] =3D 116, b[i] =3D 213; res =3D (unsigned char)min(b[0] ? (_Bool)-11818 : a[2], max(b[2], 1)); printf("%d\n", res); } > $ /usr/gcc-trunk/bin/gcc -O0 bug.c; ./a.out > 1 > $ /usr/gcc-trunk/bin/gcc -O1 bug.c; ./a.out > 213 > $ /usr/gcc-trunk/bin/gcc -O2 bug.c; ./a.out > 1 > $ /usr/gcc-trunk/bin/gcc -O3 bug.c; ./a.out > 1 > $ /usr/gcc-trunk/bin/gcc -Os bug.c; ./a.out > 1 When compiled with -O1, it prints the wrong result 213 instead of 1. Earlier GCCs do not have this bug. > $ /usr/gcc-trunk/bin/gcc --version Using built-in specs. COLLECT_GCC=3D/home/compilers/gcc/gcc-trunk/bin/gcc COLLECT_LTO_WRAPPER=3D/home/compilers/gcc/gcc-trunk/bin/../libexec/gcc/x86_= 64-pc-linux-gnu/14.0.0/lto-wrapper Target: x86_64-pc-linux-gnu Configured with: ../gcc-trunk-source/gcc/configure --enable-languages=3Dc,c++,fortran --enable-checking=3Drelease --enable-valgrind-annotations --disable-werror --disable-libstdcxx-pch --enable-libgomp --enable-lto --enable-gold --with-plugin-ld=3Dgold --prefix=3D/usr/local/gcc-trunk Thread model: posix Supported LTO compression algorithms: zlib gcc version 14.0.0 20230703 (experimental) [master r14-2244-g1ebf37ece3] (G= CC)=