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

            Bug ID: 125100
           Summary: CONST_VECTOR in REG_EQUAL note isn't checked
           Product: gcc
           Version: 16.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
          Assignee: unassigned at gcc dot gnu.org
          Reporter: hjl.tools at gmail dot com
  Target Milestone: ---
            Target: x86

CONST_VECTOR in REG_EQUAL note isn't checked

(gdb) call debug (insn)
(insn 51 14 91 3 (set (reg:V2QI 120)
        (mem/u/c:V2QI (plus:SI (reg:SI 98)
                (const:SI (unspec:SI [
                            (symbol_ref/u:SI ("*.LC0") [flags 0x2])
                        ] UNSPEC_GOTOFF))) [0  S2 A16])) 2089
{*movv2qi_internal}
     (expr_list:REG_DEAD (reg:SI 98)
        (expr_list:REG_EQUAL (const_vector:V2QI [
                    (const_int -1 [0xffffffffffffffff]) repeated x2
                ])
            (nil))))
(gdb) 

This can be changed to

(gdb) call debug (insn)
(insn 51 14 91 3 (set (subreg:HI (reg:V2QI 120) 0)
        (const_int -1 [0xffffffffffffffff])) 101 {*movhi_internal}
     (expr_list:REG_DEAD (reg:SI 98)
        (expr_list:REG_EQUAL (const_vector:V2QI [
                    (const_int -1 [0xffffffffffffffff]) repeated x2
                ])
            (nil))))
(gdb) 

[hjl@gnu-zen4-1 pr125026]$ cat bar-2.c 
struct desc {
  char c1;
  char c2;
};
void
foo (struct desc *list, int n, int l)
{
  int j;
  for (j = 0; j < l; j++)
    list[j].c1 = list[j].c2 = -1;
  for (;j < n; j++)
    list[j].c1 = list[j].c2 = -1;
}
[hjl@gnu-zen4-1 pr125026]$
/export/build/gnu/tools-build/gcc-release-debug/build-x86_64-linux/gcc/xgcc
-B/export/build/gnu/tools-build/gcc-release-debug/build-x86_64-linux/gcc/ -m32
-mtune=generic -O2 -fPIC -march=pentiumpro -S bar-2.c
[hjl@gnu-zen4-1 pr125026]$ cat bar-2.s
        .file   "bar-2.c"
        .text
        .p2align 4
        .globl  foo
        .type   foo, @function
foo:
.LFB0:
        .cfi_startproc
        pushl   %edi
        .cfi_def_cfa_offset 8
        .cfi_offset 7, -8
        pushl   %esi
        .cfi_def_cfa_offset 12
        .cfi_offset 6, -12
        call    __x86.get_pc_thunk.si
        addl    $_GLOBAL_OFFSET_TABLE_, %esi
        pushl   %ebx
        .cfi_def_cfa_offset 16
        .cfi_offset 3, -16
        movl    24(%esp), %ecx
        movl    16(%esp), %ebx
        testl   %ecx, %ecx
        jle     .L6
        movzwl  .LC0@GOTOFF(%esi), %edx
        movl    %ebx, %eax
        leal    (%ebx,%ecx,2), %edi
        testb   $1, %cl
        je      .L3
        leal    2(%ebx), %eax
        movw    %dx, (%ebx)
        cmpl    %edi, %eax
        je      .L2
        .p2align 4
        .p2align 4
        .p2align 3
.L3:
        movw    %dx, (%eax)
        addl    $4, %eax
        movw    %dx, -2(%eax)
        cmpl    %edi, %eax
        jne     .L3
.L2:
        cmpl    %ecx, 20(%esp)
        jle     .L1
        movl    20(%esp), %edi
        leal    (%ebx,%ecx,2), %eax
        movzwl  .LC0@GOTOFF(%esi), %edx
        leal    (%ebx,%edi,2), %ecx
        movl    %ecx, %ebx
        subl    %eax, %ebx
        andl    $2, %ebx
        je      .L5
        movw    %dx, (%eax)
        addl    $2, %eax
        cmpl    %ecx, %eax
        je      .L1
        .p2align 4
        .p2align 4
        .p2align 3
.L5:
        movw    %dx, (%eax)
        addl    $4, %eax
        movw    %dx, -2(%eax)
        cmpl    %ecx, %eax
        jne     .L5
.L1:
        popl    %ebx
        .cfi_remember_state
        .cfi_restore 3
        .cfi_def_cfa_offset 12
        popl    %esi
        .cfi_restore 6
        .cfi_def_cfa_offset 8
        popl    %edi
        .cfi_restore 7
        .cfi_def_cfa_offset 4
        ret
        .p2align 4,,10
        .p2align 3
.L6:
        .cfi_restore_state
        xorl    %ecx, %ecx
        jmp     .L2
        .cfi_endproc
.LFE0:
        .size   foo, .-foo
        .section        .rodata.cst2,"aM",@progbits,2
        .align 2
.LC0:
        .byte   -1
        .byte   -1
        .section       
.text.__x86.get_pc_thunk.si,"axG",@progbits,__x86.get_pc_thunk.si,comdat
        .globl  __x86.get_pc_thunk.si
        .hidden __x86.get_pc_thunk.si
        .type   __x86.get_pc_thunk.si, @function
__x86.get_pc_thunk.si:
.LFB1:
        .cfi_startproc
        movl    (%esp), %esi
        ret
        .cfi_endproc
.LFE1:
        .ident  "GCC: (GNU) 16.0.1 20260429 (prerelease)"
        .section        .note.GNU-stack,"",@progbits
[hjl@gnu-zen4-1 pr125026]$

Reply via email to