I have a problem compiling an OpenCL kernel, and can’t explain why it happens that way.
I get the following error:
Cannot select: 0x7ff1a9871610: i64,ch = dynamic_stackalloc 0x7ff1ab114cb0, 0x7ff1a9870f10, 0x7ff1a9870710 [ORD=12] [ID=21]
0x7ff1a9870f10: i64 = bitcast 0x7ff1a9871710 [ID=19]
0x7ff1a9871710: v2i32 = IGILISD::MOVSWZ 0x7ff1a9870d10, 0x7ff1a986eb10, 0x7ff1a986eb10, 0x7ff1a986eb10 [ID=15]
0x7ff1a9870d10: i32 = Constant<8> [ID=12]
0x7ff1a986eb10: i32 = Constant<0> [ID=9]
0x7ff1a986eb10: i32 = Constant<0> [ID=9]
0x7ff1a986eb10: i32 = Constant<0> [ID=9]
0x7ff1a9870710: i64 = bitcast 0x7ff1a9871110 [ID=18]
0x7ff1a9871110: v2i32 = IGILISD::MOVSWZ 0x7ff1a986eb10, 0x7ff1a986eb10, 0x7ff1a986eb10, 0x7ff1a986eb10 [ID=14]
0x7ff1a986eb10: i32 = Constant<0> [ID=9]
0x7ff1a986eb10: i32 = Constant<0> [ID=9]
0x7ff1a986eb10: i32 = Constant<0> [ID=9]
0x7ff1a986eb10: i32 = Constant<0> [ID=9]
In function: mmul
ERROR: Build Program (-11)
which I know is caused by one of the following two lines (If I remove both of them, the kernel compiles file)
uchar valc = valuec[j] ^ ((block_b[(k+i) + block_size * ty] >> (8*j)) & 0xff) ;
and
value = value | ((int) valuec[j] << (8*j)) ;
where valuec is defined:
__private uchar valuec[bytes];
and block_b is an argument to the kernel
..,__local int* restrict block_b)
Any ideas? It has to do with the combination of the array valuec[j] and the shift operator.
I can compile the kernel with the line
valuec[j] = 0
or with the lines
uchar hello = 0;
uchar valc = hello ^ ((block_b[(k+i) + block_size * ty] >> (8*j)) & 0xff) ;
but NOT with the lines
uchar hello = valuec[j];
uchar valc = hello ^ ((block_b[(k+i) + block_size * ty] >> (8*j)) & 0xff) ;
or with the lines (where valuec[j] is definitely equal to 0)
for (int i = 0 ; i < bytes ; i++) [
valuec[i]=0;
}
uchar hello = valuec[j];
uchar valc = hello ^ ((block_b[(k+i) + block_size * ty] >> (8*j)) & 0xff) ;