Created
May 19, 2012 21:12
-
-
Save mansr/2732404 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* wrong output with pathcc -O1 | |
* the return value is not truncated to 32 bits */ | |
#include <stdio.h> | |
unsigned long foo(unsigned long a, unsigned b) | |
{ | |
b -= a; | |
return b; | |
} | |
int main(void) | |
{ | |
printf("%016lx\n", foo(2, 1)); | |
return 0; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* wrong output with pathcc -O3 | |
* the loop is incorrectly vectorised with pslld, | |
* which is not an element-wise shift as the compiler | |
* appears to believe */ | |
#include <stdio.h> | |
#define N 8 | |
void print(unsigned *v) | |
{ | |
int i; | |
for (i = 0; i < N; i++) | |
printf("v[%2d] = %08x\n", i, v[i]); | |
} | |
int main(void) | |
{ | |
unsigned v[N]; | |
unsigned i; | |
for (i = 0; i < N; i++) | |
v[i] = 1 << i; | |
print(v); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment