Closed
Description
This program should print 1:
cat wrong0.i
int printf(const char *, ...);
int *IntPtr = 0;
int Val, ValB;
int *IntPtrArr5[5] = {0, 0, 0, 0, 0};
int *IntPtr2 = &ValB;
int main() {
for (int IV1 = 0; IV1 < 5; IV1++)
IntPtrArr5[IV1] = &Val;
for (int IV2 = 1; IV2 <= 4; IV2 += 1) {
int **PtrPtr = &IntPtr2; // -> IntPtr2
int **PtrPtr2 = &IntPtr; // -> IntPtr
*PtrPtr2 = IntPtrArr5[IV2]; // -> IntPtr -> Val
*IntPtr2 ^= 1; // ValB = 1 Val = 1 (2nd iter)
*PtrPtr = IntPtrArr5[IV2]; // -> IntPtr2 -> Val
}
printf("checksum = %X\n", Val);
}
In the first iteration, IntPtr2 points to ValB and sets it to 1. Then, only in the second iteration does IntPtr2 point to Val and set that to 1. I wonder if the loopvectorizer has done something wrong, or if there is some later pass possibly that is messing it up..?
rm a.out; clang -O0 -march=z16 wrong0.i -o a.out -w; ./a.out
checksum = 1
rm a.out; clang -Os -march=z16 wrong0.i -o a.out -w -fno-vectorize -fno-slp-vectorize; ./a.out
checksum = 1
rm a.out; clang -Os -march=z16 wrong0.i -o a.out -w -fno-slp-vectorize; ./a.out
checksum = 0
Metadata
Metadata
Assignees
Type
Projects
Status
Done