[prev in list] [next in list] [prev in thread] [next in thread]
List: gcc-bugs
Subject: [Bug tree-optimization/97260] New: memcmp of constant string and local constant array not folded
From: "msebor at gcc dot gnu.org via Gcc-bugs" <gcc-bugs () gcc ! gnu ! org>
Date: 2020-09-30 23:27:48
Message-ID: bug-97260-4 () http ! gcc ! gnu ! org/bugzilla/
[Download RAW message or body]
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97260
Bug ID: 97260
Summary: memcmp of constant string and local constant array not
folded
Product: gcc
Version: 11.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: tree-optimization
Assignee: unassigned at gcc dot gnu.org
Reporter: msebor at gcc dot gnu.org
Target Milestone: ---
GCC fails to fold the memcmp call below into a constant. Clang folds it
successfully.
$ cat x.c && gcc -O2 -S -Wall -Wextra -fdump-tree-optimized=/dev/stdout
-o/dev/stdout x.c
int f (void)
{
const char a[] = "1234";
return __builtin_memcmp (a, "1234", 4);
}
.file "x.c"
.text
;; Function f (f, funcdef_no=0, decl_uid=1931, cgraph_uid=1, symbol_order=0)
f ()
{
const char a[5];
int _3;
<bb 2> [local count: 1073741824]:
a = "1234";
_3 = __builtin_memcmp (&a, "1234", 4);
a ={v} {CLOBBER};
return _3;
}
.section .rodata.str1.1,"aMS",@progbits,1
.LC0:
.string "1234"
.text
.p2align 4
.globl f
.type f, @function
f:
.LFB0:
.cfi_startproc
subq $24, %rsp
.cfi_def_cfa_offset 32
movl $4, %edx
movl $.LC0, %esi
leaq 11(%rsp), %rdi
movl $875770417, 11(%rsp)
movb $0, 15(%rsp)
call memcmp
addq $24, %rsp
.cfi_def_cfa_offset 8
ret
.cfi_endproc
.LFE0:
.size f, .-f
.ident "GCC: (GNU) 11.0.0 20200930 (experimental)"
.section .note.GNU-stack,"",@progbits=
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic