This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Gcc compiler advantage and disadvantage of gcc


>> But hopefully slightly less self serving.
>
> To be honest, it doesn't seem an unfair characterization to me.
>
> GCC could highlight the ethical and tit-for-tat benefits of the GPL, but I
> guess they do not see those as a benefit.
>
> GCC has also the benefit of being a more mature code base and, as a result,
> it has been more thoroughly tested in a wider range of codes; yet this is
> difficult to quantify and arguably Clang is more widely used today than GCC,
> just not in Linux, thus this might not be true anymore.

GCC does a much better job of optimizing. I run benchmarks for some
libraries regularly to ensure there are no regressions. GCC is
consistently 2x faster than Clang, and GCC is on-par with ICC.

It seems the slow-down is the treatment of const-expr's. Under the
laws of the physical universe as we know them, some values are fixed
at compile time won't change (regardless of their const-expr status).
GCC optimizes them (common sense), while Clang does not (expected to
somehow change).

That little slow down adds up, and it makes us do things like avoid
std::numeric_limits<T>::max() in favor of a #define instead. More
complex examples include propagating a constant using a template
parameter instead of a function parameter. GCC will realize a constant
does not change under the laws of the physical universe as we know
them; while Clang will treat the constant passed as a parameter as
something that can miraculously change after saving the source file.

Jeff


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]