Pieter Custers
2012-Jan-16 14:37 UTC
[LLVMdev] Opt pass 'Canonicalize Induction Variables' not working
Hello Tobi, Thank you for the quick reply. I updated my complete build suite with your script (http://polly.grosser.es/polly.sh). The make-test fails with some errors, the rest went smoothly; -- Exit Code: 1 Command Output (stderr): -- LLVM ERROR: Could not resolve external global address: stdout -- ******************** Testing Time: 10.01s ******************** Failing Tests (3): Polly :: CodeGen/do_pluto_matmult.ll Polly :: CodeGen/single_do_loop_int_max_iterations.ll Polly :: CodeGen/single_do_loop_scev_replace.ll Expected Passes : 104 Expected Failures : 29 Unexpected Failures: 3 make: *** [polly-test] Error 1 When I try your command 'clang -Xclang -load ${POLLY_DLIB} ${FILE}.c -o ${FILE}.ll -S -emit-llvm -mllvm -polly -O0' if fails with the following errors: -------------------------------------- clang: warning: /Developer/llvm_build/tools/polly/Debug+Asserts/lib/LLVMPolly.dylib: 'linker' input unused when '-S' is present clang: warning: argument unused during compilation: '-mllvm' clang: warning: argument unused during compilation: '-polly' Error opening '-o': dlopen(-o, 9): image not found -load request ignored. error: error reading 'indvar.ll' -------------------------------------- I tried a different order of arguments to no avail. My CLang version is 1.0.2 Also the '-enable-iv-rewrite' has no effect. Any ideas? Thanks in advance, Pieter On 16 jan 2012, at 15:01, Tobias Grosser wrote:> On 01/16/2012 01:19 PM, Pieter Custers wrote: >> I am new to LLVM and I've a question about the optimization passes and >> in particular about the loop transformation passes. I've setup the LLVM >> tool-chain with Polly installed. >> >> The following example is causing problems with me: >> http://llvm.org/docs/Passes.html#indvars >> >> The input is a .c file with the following loops: >> >> # 01 Standard, N=100 >> for (i=0; i<N; i++) >> b[i] = a[i] + 5; >> >> # 02 Example loop -indvars >> for (i = 7; i*i < 1000; ++i) >> b[i] = 4; >> >> # 03 Start at 1 instead of 0 >> for (i = 1; i<10; i++) >> b[i] = 3; >> >> I have the latest LLVM build installed on Mac OSX 10.6.8. >> >> A script with (among others) the following lines is used: >> >> ----------------------------------------------------------------------------------------------------- >> POLLY_DLIB=/Developer/llvm_build/tools/polly/Debug+Asserts/lib/LLVMPolly.dylib >> alias opt="/Developer/llvm_build/Debug+Asserts/bin/opt -load ${POLLY_DLIB}" >> alias llvm-as="/Developer/llvm_build/Debug+Asserts/bin/llvm-as" >> >> # Set input filename >> FILE="indvar" >> >> # Run clang to generate LLVM-IR >> clang -S -emit-llvm ${FILE}.c -o ${FILE}.s >> >> # Make the human readable format into bitcode format >> llvm-as ${FILE}.s -o ${FILE}.bc >> >> # Prepare the LLVM-Bytecode into canonical form >> opt -S -mem2reg -loop-simplify -indvars ${FILE}.bc > ${FILE}.ll >> ----------------------------------------------------------------------------------------------------- >> >> >> What I want (and what is not working) is that loop 2 and loop 3 are >> transformed into a loop starting at 0 with stride 1 (natural loop). >> Subsequent passes need this to output information to form a Polyhedral >> model (PHM). >> >> Up to now, only the first loop is recognized as natural loop (as it >> already is one) and information about the loop is outputted as PHM. The >> other two loops aren't changed. >> >> Can somebody give me some advise? Maybe I'm using the wrong passes or in >> the wrong order? > > Hi Pieter, > > the -indvars pass does by default not generate canonical induction variables. Most LLVM passes where converted to work without canonical induction variables. For Polly those induction variables are (still) required. You can enable the relevant conversion by adding > -enable-iv-rewrite to the opt flags. > > In general, the to code for Polly a larger set of canonicalization passes is required. They can be run from clang with > > clang -Xclang -load ${POLLY_DLIB} ${FILE}.c -o ${FILE}.ll -S -emit-llvm -mllvm -polly -O0 > > You need to make sure that Polly, LLVM and clang are compiled from the same source version. > > Cheers > Tobi
Tobias Grosser
2012-Jan-16 14:56 UTC
[LLVMdev] Opt pass 'Canonicalize Induction Variables' not working
On 01/16/2012 03:37 PM, Pieter Custers wrote:> Hello Tobi, > > Thank you for the quick reply. > > I updated my complete build suite with your script (http://polly.grosser.es/polly.sh). The make-test fails with some errors, the rest went smoothly; > > -- > Exit Code: 1 > Command Output (stderr): > -- > LLVM ERROR: Could not resolve external global address: stdout > -- > > ******************** > Testing Time: 10.01s > ******************** > Failing Tests (3): > Polly :: CodeGen/do_pluto_matmult.ll > Polly :: CodeGen/single_do_loop_int_max_iterations.ll > Polly :: CodeGen/single_do_loop_scev_replace.llThat is interesting. Can you send me the individual error messages? Are you using a 32bit platform?> > Expected Passes : 104 > Expected Failures : 29 > Unexpected Failures: 3 > make: *** [polly-test] Error 1 > > When I try your command 'clang -Xclang -load ${POLLY_DLIB} ${FILE}.c -o ${FILE}.ll -S -emit-llvm -mllvm -polly -O0' if fails with the following errors:The command to prepare the code for Polly was incorrect. I missed a '-Xclang' option. The correct one is: clang -Xclang -load -Xclang ${POLLY_DLIB} ${FILE}.c -o ${FILE}.ll -S -emit-llvm -mllvm -polly -O0 to also enable -enable-iv-rewrite you need: clang -Xclang -load -Xclang ${POLLY_DLIB} ${FILE}.c -o ${FILE}.ll -S -emit-llvm -mllvm -polly -O0 -mllvm -enable-iv-rewrite. I just tried to detect the scops myself. I used for this the following command: alias pollycc='~/Projekte/polly/build_clang/bin/clang -Xclang -load \ -Xclang ~/Projekte/polly/build_clang/lib/LLVMPolly.so' pollycc -mllvm -polly-show test.c -c -mllvm -enable-iv-rewrite -mllvm -polly -O3 It detects all three loops. Can you reproduce this? Cheers Tobi -------------- next part -------------- A non-text attachment was scrubbed... Name: test.c Type: text/x-csrc Size: 188 bytes Desc: not available URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20120116/d7773926/attachment.c>
Pieter Custers
2012-Jan-16 15:14 UTC
[LLVMdev] Opt pass 'Canonicalize Induction Variables' not working
Hey Tobi, My CLang version is very old (1.0.2), I have manually installed the latest version from SVN and I am compiling LLVM again right now. Is it right that CLang is not in the standard LLVM repos (svn checkout http://llvm.org/svn/llvm-project/llvm/trunk) as indicated on http://polly.grosser.es/get_started.html? This are the instructions I followed to install my tools. I will get back to you when I've results. Cheers, Pieter On 16 jan 2012, at 15:56, Tobias Grosser wrote:> On 01/16/2012 03:37 PM, Pieter Custers wrote: >> Hello Tobi, >> >> Thank you for the quick reply. >> >> I updated my complete build suite with your script (http://polly.grosser.es/polly.sh). The make-test fails with some errors, the rest went smoothly; >> >> -- >> Exit Code: 1 >> Command Output (stderr): >> -- >> LLVM ERROR: Could not resolve external global address: stdout >> -- >> >> ******************** >> Testing Time: 10.01s >> ******************** >> Failing Tests (3): >> Polly :: CodeGen/do_pluto_matmult.ll >> Polly :: CodeGen/single_do_loop_int_max_iterations.ll >> Polly :: CodeGen/single_do_loop_scev_replace.ll > > That is interesting. Can you send me the individual error messages? Are you using a 32bit platform? > >> >> Expected Passes : 104 >> Expected Failures : 29 >> Unexpected Failures: 3 >> make: *** [polly-test] Error 1 >> >> When I try your command 'clang -Xclang -load ${POLLY_DLIB} ${FILE}.c -o ${FILE}.ll -S -emit-llvm -mllvm -polly -O0' if fails with the following errors: > > The command to prepare the code for Polly was incorrect. I missed a '-Xclang' option. The correct one is: > > clang -Xclang -load -Xclang ${POLLY_DLIB} ${FILE}.c -o ${FILE}.ll -S -emit-llvm -mllvm -polly -O0 > > to also enable -enable-iv-rewrite you need: > > clang -Xclang -load -Xclang ${POLLY_DLIB} ${FILE}.c -o ${FILE}.ll -S -emit-llvm -mllvm -polly -O0 -mllvm -enable-iv-rewrite. > > I just tried to detect the scops myself. I used for this the following command: > > alias pollycc='~/Projekte/polly/build_clang/bin/clang -Xclang -load \ > -Xclang ~/Projekte/polly/build_clang/lib/LLVMPolly.so' > > pollycc -mllvm -polly-show test.c -c -mllvm -enable-iv-rewrite -mllvm -polly -O3 > > It detects all three loops. Can you reproduce this? > > Cheers > Tobi > <test.c>-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20120116/2024c515/attachment.html>
Maybe Matching Threads
- [LLVMdev] Opt pass 'Canonicalize Induction Variables' not working
- [LLVMdev] Opt pass 'Canonicalize Induction Variables' not working
- [LLVMdev] Opt pass 'Canonicalize Induction Variables' not working
- [LLVMdev] Opt pass 'Canonicalize Induction Variables' not working
- [LLVMdev] [Polly] GSoC Proposal: Reducing LLVM-Polly Compiling overhead