From: Claudiu Zissulescu Ianculescu <claziss@gmail.com>
To: gcc@gcc.gnu.org
Subject: Possible regression in DF analysis
Date: Thu, 8 Dec 2022 12:40:01 +0200 [thread overview]
Message-ID: <CAL0iMy2hQUyt8vyXSvdt9RvB3WTKFc6zWJqtQDiKNuJ+ZtwEPQ@mail.gmail.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 2336 bytes --]
Hi,
I've stumbled over a potential issue related to Dataflow analysis,
and maybe you can help me with it. It can be reproduced for AARCH64
but other architectures are affected as well.
I have the next snip before CSE1 pass:
(insn 14 11 15 3 (set (reg:CC 66 cc)
(compare:CC (reg/v:SI 98 [ bytes ])
(const_int 8 [0x8]))) "bad_cc.c":11:8 406 {cmpsi}
(nil))
(jump_insn 15 14 16 3 (set (pc)
(if_then_else (gtu (reg:CC 66 cc)
(const_int 0 [0]))
(label_ref 27)
(pc))) "bad_cc.c":11:8 15 {condjump}
(int_list:REG_BR_PROB 955630228 (nil))
-> 27)
(note 16 15 17 4 [bb 4] NOTE_INSN_BASIC_BLOCK)
(insn 17 16 18 4 (set (reg:CC 66 cc)
(compare:CC (reg/v:SI 98 [ bytes ])
(const_int 8 [0x8]))) "bad_cc.c":12:10 406 {cmpsi}
(nil))
(jump_insn 18 17 19 4 (set (pc)
(if_then_else (eq (reg:CC 66 cc)
(const_int 0 [0]))
(label_ref:DI 34)
(pc))) "bad_cc.c":12:10 15 {condjump}
(int_list:REG_BR_PROB 365072228 (nil))
-> 34)
The CSE1 optimizes the second comparison (i.e., INSN 17) as it is similar with
the one from INSN 14.
However, after this optimization I get the CC reg being dead after
JUMP_INSN 15, which may lead to wrong code gen. Here it is the dump
from fwprop1:
(insn 14 11 15 3 (set (reg:CC 66 cc)
(compare:CC (reg/v:SI 98 [ bytes ])
(const_int 8 [0x8]))) "bad_cc.c":11:8 406 {cmpsi}
(nil))
(jump_insn 15 14 16 3 (set (pc)
(if_then_else (gtu (reg:CC 66 cc)
(const_int 0 [0]))
(label_ref 27)
(pc))) "bad_cc.c":11:8 15 {condjump}
(expr_list:REG_DEAD (reg:CC 66 cc)
(int_list:REG_BR_PROB 955630228 (nil)))
-> 27)
(note 16 15 18 4 [bb 4] NOTE_INSN_BASIC_BLOCK)
(jump_insn 18 16 19 4 (set (pc)
(if_then_else (eq (reg:CC 66 cc)
(const_int 0 [0]))
(label_ref:DI 34)
(pc))) "bad_cc.c":12:10 15 {condjump}
(expr_list:REG_DEAD (reg:CC 66 cc)
(int_list:REG_BR_PROB 365072228 (nil)))
-> 34)
Please observe the REG_DEAD note on the both jump instructions.
I see this behaviour in GCC 12.2.1 release for AARCH64, but I cannot
see it for GCC 10.x
A test code snip is attached, and it needs to be compiled with aarch64
backend using -Os option.
[-- Attachment #2: bad_cc.c --]
[-- Type: text/x-csrc, Size: 309 bytes --]
typedef unsigned int uint32_t;
typedef unsigned char uint8_t;
void foo (uint32_t *src, uint8_t *c, uint32_t bytes)
{
uint8_t *ctarget;
for (;;) {
c[0] = src[0] & 0xff;
if (bytes <= 8) {
if (bytes < 8) {
ctarget[4] = c[4];
}
return;
}
bytes -= 8;
c += 8;
}
}
next reply other threads:[~2022-12-08 10:40 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-12-08 10:40 Claudiu Zissulescu Ianculescu [this message]
2022-12-08 11:33 ` Eric Botcazou
2022-12-08 11:51 ` Claudiu Zissulescu Ianculescu
2022-12-13 8:41 ` Eric Botcazou
2022-12-13 12:30 ` Claudiu Zissulescu Ianculescu
2022-12-13 16:53 ` Claudiu Zissulescu Ianculescu
2022-12-13 17:01 ` Richard Biener
2022-12-13 17:38 ` Claudiu Zissulescu Ianculescu
2022-12-14 10:37 ` Claudiu Zissulescu Ianculescu
2022-12-14 11:06 ` Richard Biener
2022-12-14 11:30 ` Claudiu Zissulescu Ianculescu
2022-12-14 12:39 ` Richard Biener
2022-12-17 0:33 ` Jeff Law
[not found] ` <CAL0iMy1ad0PmprQdu6BMhHdivPz--1Yq72+n02Lj-SmxhZmxQQ@mail.gmail.com>
2022-12-20 12:34 ` Fwd: " Claudiu Zissulescu Ianculescu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CAL0iMy2hQUyt8vyXSvdt9RvB3WTKFc6zWJqtQDiKNuJ+ZtwEPQ@mail.gmail.com \
--to=claziss@gmail.com \
--cc=gcc@gcc.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).