public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug rtl-optimization/114208] New: DSE deletes a store that is not dead
@ 2024-03-02  9:45 gjl at gcc dot gnu.org
  2024-03-02  9:52 ` [Bug rtl-optimization/114208] RTL " pinskia at gcc dot gnu.org
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: gjl at gcc dot gnu.org @ 2024-03-02  9:45 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114208

            Bug ID: 114208
           Summary: DSE deletes a store that is not dead
           Product: gcc
           Version: 14.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: rtl-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: gjl at gcc dot gnu.org
  Target Milestone: ---

Created attachment 57594
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=57594&action=edit
Reduced C test case

$ avr-gcc -mmcu=attiny40 bug-dse.c -S -Os -dp -mfuse-add=3 -fdse

the following C test case:

struct S { char a, b; };

__attribute__((__noinline__,__noclone__))
void test (const struct S *s)
{
    if (s->a != 3 || s->b != 4)
        __builtin_abort();
}

int main (void)
{
    struct S s = { 3, 4 };
    test (&s);

  return 0;
}

Then with DSE off (-fno-dse), main has a store of 3 into s.a:

main:
        ...
        ldi r20,lo8(3)   ;  22  [c=4 l=1]  movqi_insn/1
        ld __tmp_reg__,Y+        ;  24  [c=4 l=1]  *addhi3/3
        st Y+,r20                ;  48  [c=4 l=1]  movqi_insn/2
        ldi r20,lo8(4)   ;  27  [c=4 l=1]  movqi_insn/1
        st Y,r20                 ;  30  [c=4 l=1]  movqi_insn/2
        ...

but with DSE on, pass .dse2 removes the first store (insn 48, and in the wake
also insn 22) that sets s.a to 3:

main:
        ...
        ldi r20,lo8(4)   ;  27  [c=4 l=1]  movqi_insn/1
        subi r28,-2      ;  29  [c=4 l=2]  *addhi3/3
        sbci r29,-1
        st Y,r20                 ;  30  [c=4 l=1]  movqi_insn/2
        ...

Configured with: ../../source/gcc-master/configure --target=avr --disable-nls
--with-dwarf2 --with-gnu-as --with-gnu-ld --disable-shared
--enable-languages=c,c++
Thread model: single
Supported LTO compression algorithms: zlib
gcc version 14.0.1 20240302 (experimental) (GCC)

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2024-03-04 15:22 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-03-02  9:45 [Bug rtl-optimization/114208] New: DSE deletes a store that is not dead gjl at gcc dot gnu.org
2024-03-02  9:52 ` [Bug rtl-optimization/114208] RTL " pinskia at gcc dot gnu.org
2024-03-02 13:02 ` gjl at gcc dot gnu.org
2024-03-02 15:06 ` gjl at gcc dot gnu.org
2024-03-04 10:01 ` rguenth at gcc dot gnu.org
2024-03-04 15:22 ` gjl at gcc dot gnu.org

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).