[llvm-dev] clang optimizations

via llvm-dev llvm-dev at lists.llvm.org
Mon Jan 25 03:48:38 PST 2021


Hello,

 

I am trying to apply level 3 of optimizations to a simple program. If I run:

 

clang -S -O3 -emit-llvm test.cpp -o testo.ll

 

all seems OK, the result testo.ll is highly optimized.

 

However if I attempt the same using:

 

clang -S -emit-llvm test.cpp -o a.ll

              opt-10 -S --O3 a.ll -o test.ll

 

then there is no optimization performed. 

 

The test program that I am using is:

 

#include <iostream>

 

__attribute__((always_inline)) void ADD(bool en, int x, int y, bool &ok, int
&r)

{

              if(en)

              {

                             ok = true;

                             r = x + y;

              }

              else

              {

                             ok = false;

                             r = 0;

              }             

}

 

void test()

{

              bool en = true;

              int x = 123;

              int y = 321;

              int z;

              bool ok;

              ADD(en, x, y, ok, z);

              std::cout << z;

}

 

Best regards,

 

Viorel

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20210125/982ecdc3/attachment.html>


More information about the llvm-dev mailing list