This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Why -fPIC stops some optimization?
- From: Denis Zaitsev <zzz at anda dot ru>
- To: gcc at gcc dot gnu dot org, linux-gcc at vger dot kernel dot org
- Date: Fri, 9 Jul 2004 21:02:30 +0600
- Subject: Why -fPIC stops some optimization?
I have met such a behaviour while compiling GLIBC for x86. A
construct which suffers looks like:
#define __xyz(x,y,z) ({ \
... \
size_t __n= (z); \
... \
switch (__n) { \
case ... \
... \
} \
... \
})
This macro is intended for use with some constant z
(__builtin_constant_p(z) is true). And when this macro is used such a
way, GCC should unroll (or what is the word for this?) the switch into
the only branch which is needed. And GCC does this optimization, but
only not for the -fPIC case. There GCC emits the whole body for the
switch operator and then does just a jump for the correct branch.
Why? Or it is some expected misbehaviour for the -fPIC case?
GCC-3.3.2.
Thanks in advance.