public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/102756] New: [12 Regression] Vectorizer change creates poor code for c-c++-common/torture/vector-compare-2.c
@ 2021-10-15  0:16 law at gcc dot gnu.org
  2021-10-15  0:29 ` [Bug tree-optimization/102756] [12 Regression] Complete unrolling is too senative to PRE; c-c++-common/torture/vector-compare-2.c pinskia at gcc dot gnu.org
                   ` (9 more replies)
  0 siblings, 10 replies; 11+ messages in thread
From: law at gcc dot gnu.org @ 2021-10-15  0:16 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 102756
           Summary: [12 Regression] Vectorizer change creates poor code
                    for c-c++-common/torture/vector-compare-2.c
           Product: gcc
           Version: 12.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: law at gcc dot gnu.org
  Target Milestone: ---

The visium-elf port is a bit broken in that any code which calls abort will
fail to link.   This has turned out to be useful in that it has pointed out
cases where the quality of our code generation has suffered.

The change to turn on the vectorizer by default at -O2 is yet another example.

c-c++-common/torture/vector-compare-2.c before the vectorizer change compiled
down to this code at -O2:



        .file   "j.c"
        .text
        .align  4
        .p2align 8
        .global foo
        .type   foo, @function
foo:
        moviu   r9,65535
        movil   r9,65533
        write.l (r1),r9
        write.l 1(r1),r9
        write.l 2(r1),r9
        bra     tr,r21,r0               ;return
         write.l 3(r1),r9
        .size   foo, .-foo
        .section        .text.startup,"ax",@progbits
        .align  4
        .p2align 8
        .global main
        .type   main, @function
main:
        bra     tr,r21,r0               ;return
         moviq   r1,0           ;movsi  r  J
        .size   main, .-main
        .ident  "GCC: (GNU) 12.0.0 20211008 (experimental)"


Of particular note "main" does _not_ call abort.  The optimizers have figured
everything out and realized that it should never abort.

After enabling the vectorizer at -O2 we get:
        .file   "j.c"
        .text
        .align  4
        .p2align 8
        .global foo
        .type   foo, @function
foo:
        moviu   r9,65535
        movil   r9,65533
        write.l (r1),r9
        write.l 1(r1),r9
        write.l 2(r1),r9
        bra     tr,r21,r0               ;return
         write.l 3(r1),r9
        .size   foo, .-foo
        .section        .text.startup,"ax",@progbits
        .align  4
        .p2align 8
        .global main
        .type   main, @function
main:
        subi    sp,36
        moviq   r10,23          ;movsi  r  J
        write.l (sp),fp
        move.l  fp,sp           ;stack_save
        add.l   r8,fp,r10
        lsr.l   r8,r8,4
        asl.l   r8,r8,4
        moviu   r9,65535
        write.l 1(sp),r21
        movil   r9,65533
        write.l (r8),r9
        write.l 1(r8),r9
        write.l 2(r8),r9
        write.l 3(r8),r9
        move.l  r10,r8
        moviq   r8,16           ;movsi  r  J
        add.l   r7,r10,r8
.L5:
        read.l  r8,(r10)
        cmp.l   r8,r9
        brr     ne,.L8
         addi    r10,4
        cmp.l   r10,r7
        brr     ne,.L5
         moviq   r1,0           ;movsi  r  J
        read.l  fp,(sp)
        read.l  r21,1(sp)
        bra     tr,r21,r0               ;return
         addi    sp,36          ;stack pop
.L8:
        moviu   r10,%u abort
        movil   r10,%l abort
        bra     tr,r10,r21
         nop            ;call
        .size   main, .-main
        .ident  "GCC: (GNU) 12.0.0 20211008 (experimental)"


Note how there's a call to abort starting at the label .L8.  And more generally
the code in "main" is considerably larger and more complex.

This is a code quality regression.

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

end of thread, other threads:[~2023-05-08 12:22 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-15  0:16 [Bug tree-optimization/102756] New: [12 Regression] Vectorizer change creates poor code for c-c++-common/torture/vector-compare-2.c law at gcc dot gnu.org
2021-10-15  0:29 ` [Bug tree-optimization/102756] [12 Regression] Complete unrolling is too senative to PRE; c-c++-common/torture/vector-compare-2.c pinskia at gcc dot gnu.org
2021-10-15  0:29 ` pinskia at gcc dot gnu.org
2021-10-15  6:25 ` rguenth at gcc dot gnu.org
2021-10-15 14:44 ` law at gcc dot gnu.org
2021-11-17 16:28 ` law at gcc dot gnu.org
2021-11-17 16:29 ` law at gcc dot gnu.org
2022-01-19  8:22 ` rguenth at gcc dot gnu.org
2022-05-06  8:31 ` [Bug tree-optimization/102756] [12/13 " jakub at gcc dot gnu.org
2022-07-26 13:23 ` rguenth at gcc dot gnu.org
2023-05-08 12:22 ` [Bug tree-optimization/102756] [12/13/14 " rguenth 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).