Hi all,
i'm trying to compile some small ANSI C benchmarks to PTX assembly. For this purpose, I'm using the NVPTX backend, introduced in the LLVM 3.2 release.
It appears that certain LLVM constructs cannot be compiled to PTX. The problems mostly deal with handling of arrays. I also don't get any debug info when these problems.
I use "llc" for compiling regular .ll files to PTX using the "nvptx" backend. The llc options are as follows (omitting these options also present the same problems):
-nacdrvtest -asm-verbose -stats -print-before-all -print-after-all -time-passes
1. Only programs that make no use of arrays appear to always be processed correctly by llc (nvptx target). Some programs using arrays, make llc "hang" (runs endlessly).
2. One small C function exposing this behavior is as follows:
// start here
int arrtest (int x, int y) {
unsigned char b[3]={0x10,0x30,0x55};
b[0] = (255 - b[x]) + b[y]; // doesn't work!
// b[0] = (255 - b[0]) + b[1]; // works
b[1] = x - y;
b[2] = x * y;
return b[0];
}
// end here
3. A change that makes this function compilable (also visible in the comments)
Change:
b[0] = (255 - b[x]) + b[y];
to:
b[0] = (255 - b[0]) + b[1];
Similarly, even the use of a single variable indexing (e.g. b[x]) doesn't work.
Please note that if variable indexing is not used, then PTX assembly is generated. The problems seems related to the support/handling of variable indexing.
However, the same code is always processed by other target backends (x86, mips).
Is this behavior expected by the NVPTX backend?
I understand that PTX is primarily targeted by OpenCL, however I would expect that the backend would issue some warnings on unimplemented features and not just run endlessly with no messages whatsoever.
Best regards
Nikolaos Kavvadias