From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 6CE9D3857718; Thu, 6 Jul 2023 19:05:24 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 6CE9D3857718 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1688670324; bh=/hyLGe0vN394SSS8zTlTl1ywlmAy5E8J+5/mgL3DA4Y=; h=From:To:Subject:Date:In-Reply-To:References:From; b=eGdXJbYixsPAbG7OfgNGITrJ0GEQ7vTbwAnvvL6IZjOka/Z6Q6o/ko/WVJuk/0I9s +mlcAibf7vcW66WjkYvXB64alrfMcF7pWKTYW/D4EAn0opkoMaGUuK2S62f9V+kFWq wk6ypsYXDOwpYyIoc28AacwM3AysMVuhqHNxazeE= From: "pinskia at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug rtl-optimization/104914] [MIPS] wrong comparison with scrabbled int value Date: Thu, 06 Jul 2023 19:05:23 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: rtl-optimization X-Bugzilla-Version: 12.0 X-Bugzilla-Keywords: wrong-code X-Bugzilla-Severity: normal X-Bugzilla-Who: pinskia at gcc dot gnu.org 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: component everconfirmed cf_reconfirmed_on bug_status cf_known_to_fail 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=3D104914 Andrew Pinski changed: What |Removed |Added ---------------------------------------------------------------------------- Component|target |rtl-optimization Ever confirmed|0 |1 Last reconfirmed| |2023-07-06 Status|UNCONFIRMED |NEW Known to fail| |11.2.0 --- Comment #7 from Andrew Pinski --- The initial RTL has a signed extend in there: (insn 20 19 23 2 (set (reg/v:DI 200 [ val+-4 ]) (sign_extend:DI (subreg:SI (reg/v:DI 200 [ val+-4 ]) 4))) "/app/example.cpp":7:29 -1 (nil)) (jump_insn 23 20 24 2 (set (pc) (if_then_else (le (subreg/s/u:SI (reg/v:DI 200 [ val+-4 ]) 4) (const_int 0 [0])) (label_ref 32) (pc))) "/app/example.cpp":8:5 -1 (int_list:REG_BR_PROB 440234148 (nil)) -> 32) Before combine also looks fine: (insn 20 19 23 2 (set (reg/v:DI 200 [ val+-4 ]) (sign_extend:DI (subreg:SI (reg/v:DI 200 [ val+-4 ]) 4))) "/app/example.cpp":7:29 235 {extendsidi2} (nil)) (jump_insn 23 20 24 2 (set (pc) (if_then_else (le (subreg/s/u:SI (reg/v:DI 200 [ val+-4 ]) 4) (const_int 0 [0])) (label_ref 32) (pc))) "/app/example.cpp":8:5 471 {*branch_ordersi} (expr_list:REG_DEAD (reg/v:DI 200 [ val+-4 ]) (int_list:REG_BR_PROB 440234148 (nil))) -> 32) But combine does the wrong thing: Trying 20 -> 23: 20: r200:DI=3Dsign_extend(r200:DI#4) 23: pc=3D{(r200:DI#4<=3D0)?L32:pc} REG_DEAD r200:DI REG_BR_PROB 440234148 Successfully matched this instruction: (set (pc) (if_then_else (le (subreg:SI (reg/v:DI 200 [ valD.1959+-4 ]) 4) (const_int 0 [0])) (label_ref 32) (pc))) allowing combination of insns 20 and 23 original costs 4 + 16 =3D 20 replacement cost 16 deferring deletion of insn with uid =3D 20. modifying insn i3 23: pc=3D{(r200:DI#4<=3D0)?L32:pc} REG_BR_PROB 440234148 REG_DEAD r200:DI deferring rescan insn with uid =3D 23. Instead of a subreg here, it should have been a truncate.=