From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id AEF3E389780E; Fri, 1 May 2020 01:37:16 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org AEF3E389780E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1588297036; bh=1RSMOwFMgbUCpU7bWq0mmvDKrzXNUQa7a2FOmNhJC0I=; h=From:To:Subject:Date:In-Reply-To:References:From; b=CdH9GRcScUWOSSGZAZSyseWha0XvUno9oqR0ATaoLp/qPN0RVqXV4vxvJenOETLOV bcdiupcc1qFqBEpf4CUGc2RDA4BQuYwO7FQbge3CDqIKA91YASH9bI2mPNfmTAZSug /0D9tYUTdWyHXL9L20sxjmyhmYJ942zWQfHS48SQ= From: "pinskia at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/94899] Failure to optimize out add before compare with INT_MIN Date: Fri, 01 May 2020 01:37:16 +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: 10.0 X-Bugzilla-Keywords: missed-optimization X-Bugzilla-Severity: normal X-Bugzilla-Who: pinskia at gcc dot gnu.org X-Bugzilla-Status: RESOLVED X-Bugzilla-Resolution: INVALID 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_status resolution 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: Fri, 01 May 2020 01:37:16 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D94899 Andrew Pinski changed: What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |RESOLVED Resolution|--- |INVALID --- Comment #2 from Andrew Pinski --- /* X + Z < Y + Z is the same as X < Y when there is no overflow. */ (for op (lt le ge gt) (simplify (op (plus:c @0 @2) (plus:c @1 @2)) (if (ANY_INTEGRAL_TYPE_P (TREE_TYPE (@0)) && TYPE_OVERFLOW_UNDEFINED (TREE_TYPE (@0))) (op @0 @1)))) ... /* X - Z < Y - Z is the same as X < Y when there is no overflow. */ (for op (lt le ge gt) (simplify (op (minus @0 @2) (minus @1 @2)) (if (ANY_INTEGRAL_TYPE_P (TREE_TYPE (@0)) && TYPE_OVERFLOW_UNDEFINED (TREE_TYPE (@0))) (op @0 @1)))) This is invalid as 0x80000000 is unsigned (C90/C++03) or long (C99/C++11) in type. Which means then overflow is not undefined but rather wrapping. THIS ALSO means clang is broken.=