This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: small test case for memset problem
- From: Jan Hubicka <jh at suse dot cz>
- To: Andi Kleen <ak at suse dot de>, gcc at gcc dot gnu dot org, roger at eyesopen dot com
- Cc: jh at suse dot cz
- Date: Sun, 4 Jan 2004 13:55:48 +0100
- Subject: Re: small test case for memset problem
- References: <20040104012852.5da8744c.ak@suse.de>
>
> Jan wanted a small test case for the memset issue I reported earlier.
>
> Compile this with the 9.0 compiler on x86-64 with -O2:
>
> static inline __attribute__((always_inline)) void bitmap_clear(unsigned long *bitmap, int bits)
> {
> __builtin_memset((unsigned long *)bitmap, 0, (((bits)+64 -1)/64)*sizeof(unsigned long));
> }
>
> static void bla(unsigned long *nodes)
> {
> bitmap_clear(nodes, (1 << 3));
> }
>
> and you get
>
> .text
> .p2align 4,,15
> .type bla, @function
> bla:
> .LFB4:
> cld
> movl $1, %ecx
> xorl %eax, %eax
> rep
> stosq
> ret
>
> Clearly it should be just
>
> bla:
> movq $0,(%rdi)
> ret
The actual problem is that inliner don't constant propagate "bits"
argument into builtin call. This can be fixed by adding "const"
modifier to the declaration, but it unforutnately won't solve the
problem (it does if bits is directly passed to builtin).
In this case we don't re-fold the operand so we end up with complex
constant expression. Is there any easy way to deal with this?
I would say that for 3.4 we would get such we having to use macro for
this parituclar case...
Honza
>
> -Andi