Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
| From | Melzzzzz <mel@zzzzz.com> |
|---|---|
| Newsgroups | comp.lang.c++, comp.lang.c |
| Subject | Why compiler is able to vectorize on int but not on unsigned |
| Date | 2014-12-03 11:19 +0100 |
| Organization | albasani.net |
| Message-ID | <20141203111909.5ec8c7fc@maxa-pc> (permalink) |
Cross-posted to 2 groups.
Function in question is this:
int testNormal(const vector_t & ghs, const vector_t & lhs) {
int max = 0;
int tempMax;
for (unsigned k = 0; k < ghs.size(); k++) {
tempMax = lhs[k] + ghs[k];
if (max < tempMax) {
max = tempMax;
}
}
return max;
}
where: typedef vector<int> vector_t;
(could be also plain array so I post this to clc as well)
If k is unsigned both clang and gcc are not able to vectorize, producing
scalar code.
But, if k is int, both clang and gcc vectorize code producing 5x(SSE)
or 10x(AVX2) faster loop!
I am really stumbled as I can't see why type of index variable restricts
this optimization.
Back to comp.lang.c | Previous | Next — Next in thread | Find similar | Unroll thread
Why compiler is able to vectorize on int but not on unsigned Melzzzzz <mel@zzzzz.com> - 2014-12-03 11:19 +0100
Re: Why compiler is able to vectorize on int but not on unsigned James Kuyper <jameskuyper@verizon.net> - 2014-12-03 08:02 -0500
Re: Why compiler is able to vectorize on int but not on unsigned jacob navia <jacob@spamsink.net> - 2014-12-03 14:57 +0100
Re: Why compiler is able to vectorize on int but not on unsigned Tim Prince <tprince@computer.org> - 2014-12-03 09:23 -0500
Re: Why compiler is able to vectorize on int but not on unsigned James Kuyper <jameskuyper@verizon.net> - 2014-12-03 10:03 -0500
Re: Why compiler is able to vectorize on int but not on unsigned Victor Bazarov <v.bazarov@comcast.invalid> - 2014-12-03 09:24 -0500
Re: Why compiler is able to vectorize on int but not on unsigned Richard Heathfield <invalid@see.sig.invalid> - 2014-12-03 14:36 +0000
Re: Why compiler is able to vectorize on int but not on unsigned Melzzzzz <mel@zzzzz.com> - 2014-12-03 16:03 +0100
Re: Why compiler is able to vectorize on int but not on unsigned Victor Bazarov <v.bazarov@comcast.invalid> - 2014-12-03 10:27 -0500
Re: Why compiler is able to vectorize on int but not on unsigned Melzzzzz <mel@zzzzz.com> - 2014-12-03 16:43 +0100
Why compiler is able to vectorize on int but not on unsigned "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2014-12-03 06:35 -0800
Re: Why compiler is able to vectorize on int but not on unsigned Melzzzzz <mel@zzzzz.com> - 2014-12-03 16:09 +0100
Re: Why compiler is able to vectorize on int but not on unsigned Alain Ketterlin <alain@dpt-info.u-strasbg.fr> - 2014-12-03 18:53 +0100
Re: Why compiler is able to vectorize on int but not on unsigned James Kuyper <jameskuyper@verizon.net> - 2014-12-03 13:13 -0500
Re: Why compiler is able to vectorize on int but not on unsigned Alain Ketterlin <alain@dpt-info.u-strasbg.fr> - 2014-12-04 22:04 +0100
Re: Why compiler is able to vectorize on int but not on unsigned Melzzzzz <mel@zzzzz.com> - 2014-12-05 10:07 +0100
Re: Why compiler is able to vectorize on int but not on unsigned Alain Ketterlin <alain@dpt-info.u-strasbg.fr> - 2014-12-05 10:42 +0100
Re: Why compiler is able to vectorize on int but not on unsigned Melzzzzz <mel@zzzzz.com> - 2014-12-05 11:29 +0100
csiph-web