[Bug middle-end/83022] New: malloc & memset -> calloc is not always an optimization
nathan at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Thu Nov 16 18:40:00 GMT 2017
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83022
Bug ID: 83022
Summary: malloc & memset -> calloc is not always an
optimization
Product: gcc
Version: 8.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: middle-end
Assignee: unassigned at gcc dot gnu.org
Reporter: nathan at gcc dot gnu.org
Target Milestone: ---
Created attachment 42623
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=42623&action=edit
exemplar
We like to optimize malloc followed by memset into a calloc call. Even when
the memset is conditional. That's well formed, but pessimizes, and noticeable
when the size is large and we do unnecessary clearing.
The attached example, compiled on x86_64 with -O results in:
_Z1mmb:
movl $1, %esi
jmp calloc
But, it causes a noticeable performance regression, as 'c' is false
sufficiently often and 's' is large sufficiently often.
More information about the Gcc-bugs
mailing list