[cfe-dev] Question about finding nested for-loops

Tobias Grosser tobias at grosser.es
Tue Jul 15 01:24:59 PDT 2014


On 15/07/2014 09:27, Anja Gerbes wrote:
> Hi All,
>
> This is my example function to explaining my problem:
>
> void BM_MatrixMultiplication_var(int NVar)
>          {
>            for(int i=0; i < NConst1; i++)                //MatrixARow
>            {
>                  for(int j=0; j < NVar; j++)             //MatrixBColumn
>                  {
>                          fResultMatrix[i][j] = 0.0;
>                          for(int k = 0; k < NVar; k++)   //MatrixAColumn
>                          {
>                                   fResultMatrix[i][j] += fMatrixA[i][k] *
> fMatrixB[k][j];
>                          }
>                  }
>            }
>          }
>
> This is my function what i want to change with clang.

Dear Anja,

I am unsure what you want to do, but in case you are working in the area 
of loop optimizations, there also exist a set of specialized tools such 
as PET (http://www.ohloh.net/p/libpet) and PPCG 
(http://www.ohloh.net/p/ppcg) which enable you to perform 
source-to-source loop transformations with clang as a parser. Pet, the 
tool that detects the loops is based on clang. By looking at its source 
code you may find a way to extract loop information.

Cheers,
Tobias




More information about the cfe-dev mailing list