- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi, everyone! Here's a simple C snippet. I compile it with icc, but the report of vectorization seems weird.
[cpp]#include
#include
#define N (1 << 20)
#define MB (1 << 20)
int main(void) {
int *a, *b, i;
size_t ms = sizeof(int) * N;
a = (int *) malloc(ms);
b = (int *) malloc(ms);
for (i = 0; i < N; ++i)
a = rand();
for (i = 0; i < N; ++i) /* not an inner loop? */
b = a;
free(a);
free(b);
return 0;
}[/cpp]
Here's how I compiled the code.
[plain]wu@mars:~ $ icc --version && icc -O2 -vec-report3 ex.c
icc (ICC) 12.1.3 20120212
Copyright (C) 1985-2012 Intel Corporation. All rights reserved.
ex.c(11): (col. 12) remark: loop was not vectorized: statement cannot be vectorized.
ex.c(12): (col. 3) remark: LOOP WAS VECTORIZED.
ex.c(12): (col. 3) remark: loop was not vectorized: not inner loop.[/plain]
The output about line (12) confused me. Is the loop of line (12) vectorized or not? Why it's detected as 'not inner loop'?
Thank you in advance!
Link Copied
2 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
This could mean there are 2 versions of the loop, or even that there is optimized code to skip it, since the compiler can see that no results are used. If code is not eliminated, it would be entirely reasonable for the compiler to fuse the loops, storing both results in the same loop.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks, Tim!
You're right! I turned on '-opt-report 3' and found out that the compiler recognized the adjacent loops, and replaced the second loop with memset.
[plain]
High Level Optimizer Report (main)
Adjacent Loops: 2 at line 10
QLOOPS 2/2/0 ENODE LOOPS 2 unknown 0 multi_exit_do 0 do 2 linear_do 2 lite_throttled 0
......
Loop at line:12 memcopy(with guard) generated [/plain]

Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page