From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 6F9C03858D20; Wed, 1 May 2024 02:22:16 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 6F9C03858D20 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1714530136; bh=dj2G5Tw0GEQb9SjujbCC+dlQk6rhVneV/Q9bYLXo7As=; h=From:To:Subject:Date:In-Reply-To:References:From; b=ZwWKJ3rBCxJofmN//RoWDGt4vdFUGBscYwtAI5NcEqPiyaYOce9WeUXCbIWWN9aTr BKLQDd623Xy1etqcrI15w9BWy8SUXqAYgrB6+DQHNh68aBuusARu6YleIeX4m9+8Kx 8sVGQOKJKRZdMFMgZLn8odiCqxCWejEkgrZIc78A= From: "pinskia at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug rtl-optimization/114902] [14/15 Regression] wrong code at -O3 with "-fno-tree-vrp -fno-expensive-optimizations -fno-tree-dominator-opts" on x86_64-linux-gnu Date: Wed, 01 May 2024 02:22:16 +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: unknown 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: 14.0 X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: component 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=3D114902 Andrew Pinski changed: What |Removed |Added ---------------------------------------------------------------------------- Component|target |rtl-optimization --- Comment #2 from Andrew Pinski --- Looks like the issue is during combine. After combine we have: ``` 12: r113:SI=3D[`b'] 13: r112:SI=3D~r113:SI REG_DEAD r113:SI REG_EQUAL ~[`b'] 14: NOTE_INSN_DELETED 15: {r109:SI=3Dsign_extract(r112:SI,0x1,0);clobber flags:CC;} REG_UNUSED flags:CC 18: NOTE_INSN_DELETED 19: NOTE_INSN_DELETED 22: r117:SI=3D0x1 21: flags:CCZ=3Dcmp(zero_extract(r112:SI,0x1,0),0) REG_DEAD r112:SI 23: r106:SI=3D{(flags:CCZ=3D=3D0)?r109:SI:r117:SI} REG_DEAD r117:SI REG_DEAD r109:SI REG_DEAD flags:CCZ REG_EQUAL {(flags:CCZ=3D=3D0)?r109:SI:0x1} ``` insn 21 is wrong. ``` Trying 15 -> 18: 15: {r109:SI=3Dsign_extract(r112:SI,0x1,0);clobber flags:CC;} REG_DEAD r112:SI REG_UNUSED flags:CC 18: flags:CCGC=3Dcmp(r109:SI,0xffffffffffffffff) Failed to match this instruction: (parallel [ (set (reg:CCZ 17 flags) (compare:CCZ (zero_extract:SI (reg:SI 112 [ _2 ]) (const_int 1 [0x1]) (const_int 0 [0])) (const_int 0 [0]))) (set (reg/v:SI 109 [ eD.2798 ]) (sign_extract:SI (reg:SI 112 [ _2 ]) (const_int 1 [0x1]) (const_int 0 [0]))) ]) Failed to match this instruction: (parallel [ (set (reg:CCZ 17 flags) (compare:CCZ (zero_extract:SI (reg:SI 112 [ _2 ]) (const_int 1 [0x1]) (const_int 0 [0])) (const_int 0 [0]))) (set (reg/v:SI 109 [ eD.2798 ]) (sign_extract:SI (reg:SI 112 [ _2 ]) (const_int 1 [0x1]) (const_int 0 [0]))) ]) Failed to match this instruction: (parallel [ (set (reg:CCZ 17 flags) (compare:CCZ (and:SI (reg:SI 112 [ _2 ]) (const_int 1 [0x1])) (const_int 0 [0]))) (set (reg/v:SI 109 [ eD.2798 ]) (sign_extract:SI (reg:SI 112 [ _2 ]) (const_int 1 [0x1]) (const_int 0 [0]))) ]) Failed to match this instruction: (parallel [ (set (reg:CCZ 17 flags) (compare:CCZ (and:SI (reg:SI 112 [ _2 ]) (const_int 1 [0x1])) (const_int 0 [0]))) (set (reg/v:SI 109 [ eD.2798 ]) (sign_extract:SI (reg:SI 112 [ _2 ]) (const_int 1 [0x1]) (const_int 0 [0]))) ]) Successfully matched this instruction: (set (reg/v:SI 109 [ eD.2798 ]) (sign_extract:SI (reg:SI 112 [ _2 ]) (const_int 1 [0x1]) (const_int 0 [0]))) Successfully matched this instruction: (set (reg:CCZ 17 flags) (compare:CCZ (zero_extract:SI (reg:SI 112 [ _2 ]) (const_int 1 [0x1]) (const_int 0 [0])) (const_int 0 [0]))) Successfully matched this instruction: (set (reg:QI 115 [ _10 ]) (ne:QI (reg:CCZ 17 flags) (const_int 0 [0]))) allowing combination of insns 15 and 18 original costs 4 + 4 =3D 12 replacement costs 4 + 4 =3D 12 modifying other_insn 19: r115:QI=3Dflags:CCZ!=3D0 REG_DEAD flags:CCGC deferring rescan insn with uid =3D 19. modifying insn i2 15: {r109:SI=3Dsign_extract(r112:SI,0x1,0);clobber flags:CC;} REG_UNUSED flags:CC deferring rescan insn with uid =3D 15. modifying insn i3 18: flags:CCZ=3Dcmp(zero_extract(r112:SI,0x1,0),0) REG_DEAD r112:SI deferring rescan insn with uid =3D 18. ``` We go from CCGC with a sign_extend to a zero_extend with CCZ. that can't be right.=