constant propagation optimization
Hi every one, I have a question about gcc optimization, I hope I am writing to the right list I compiled a simple c++ program using gcc 4.0.1 #include using namespace std; intc; calss Calcul { public: void affich() { cout << "hello world" << endl; } public void inc (int& c) { switch (c) { case 1 : c=c+1; break; case 2 : c=c+2; break; case 3 : c=c+3; break; default : c=c+0; } }; int main() { Calcul ca; c=3; ca.affich(); ca.inc(c); cout << "the value of c is" << c << endl; return 0; } I am interested in cpp optimisation (constant propagation) normally, if I compile it using g++ test.cpp -O3 -fdump-tree-all, the c variable will be considered as constant (ca.inc(c); will be replaced only by c = 6; ) This kind of optimization is well done if I declare c just before ca.inc(c)): compiling the code bellow, the ca.inc(c) is replaced by c=6; (in the test1.dom1 file) int main() { Calcul ca; ca.affich(); c=3; ca.inc(c); cout << "the value of c is" << c << endl; return 0; } Why in the fist code, c is not considered as a constant (in spite that affich() does not change c) Thank you very much Asma
Re : constant propagation optimization
thank you for your answer If I change affich() code (I put as an example an incrementation of an other variable named a), the compiler consider c as a constant (he optimize well and remove all switch cases in inc function). So the problem comes from the <<() calls in affich. Is the compiler lost when he find << calls ? (cause a lot of code is generated to affich a string ) thank you for your help. - Message d'origine De : Nathan Froyd À : charfi asma Cc : gcc@gcc.gnu.org Envoyé le : Jeudi, 5 Mars 2009, 17h33mn 28s Objet : Re: constant propagation optimization On Thu, Mar 05, 2009 at 11:39:45AM +, charfi asma wrote: > intc; > int main() > > { > > Calcul ca; > > c=3; > > ca.affich(); > > ca.inc(c); > > cout << "the value of c is" << c << endl; > > return 0; > > } [...] > int main() > > { > > Calcul ca; > > ca.affich(); > > c=3; > > ca.inc(c); > > cout << "the value of c is" << c << endl; > > return 0; > > } > > Why in the fist code, c is not considered as a constant (in spite that > affich() does not change c) Because GCC does not currently do the necessary analysis to know that affich() does not change c; it therefore makes the conservative assumption that it does. -Nathan
add new optimization pass to the GCC optimizations
Hello, Can we add our own SSA optimizations passes to GCC? is there a plugin or API that can help doing this ? (since GCC is open source) to run this optimization, can we easialy add it to other optimizations performed by chosing one of the known GCC flag: O1, O2, ... Thanks Asma
CFG generation from C/C++ and JAVA
Hello, I am interested in generating the CFG from several gcc front ends. All works fine for GCC and G++, and we are also interrested in JAVA. we have seen that GCJ is no longer maintained/distributed by GCCHowever, we do not like to compile input java code into assembly or binary code, we would like just to analyze (with our tools) the CFG produced from each front ends including the gcj front end. we downloaded the gcc 6.5.0 that contains gcj but when trying to call "gcj -v" we got this error : "libgcj.spec : Nosuch file or directory." Any idea ? we really need to evaluate the java front end even in a previous version of GCC (just to dump the Generic, gimple and cfg intermediate representations) Thank you very much ! Asma
Re: CFG generation from C/C++ and JAVA
Thank you for your help. Yes, It seems that gcj6 is not well installaed. Could you please help me to install it ? which installation instruction should I follow ? I can not installed with apt-get should I checkout the gcj 6 from git and setup it manually ? If yes, can you please give me the steps to follow ? Thank you again for your help Le jeudi 27 juin 2019 à 11:24:41 UTC+2, Richard Biener a écrit : On Wed, Jun 26, 2019 at 5:33 PM charfi asma via gcc wrote: > > Hello, > I am interested in generating the CFG from several gcc front ends. All works > fine for GCC and G++, and we are also interrested in JAVA. > we have seen that GCJ is no longer maintained/distributed by GCCHowever, we > do not like to compile input java code into assembly or binary code, we would > like just to analyze (with our tools) the CFG produced from each front ends > including the gcj front end. > we downloaded the gcc 6.5.0 that contains gcj but when trying to call "gcj > -v" we got this error : "libgcj.spec : Nosuch file or directory." > Any idea ? we really need to evaluate the java front end even in a previous > version of GCC (just to dump the Generic, gimple and cfg intermediate > representations) > Thank you very much ! it looks like you failed to build and install libjava. Please follow the install instructions, in particular you need to download ecj.jar which you likely forgot. Richard. > Asma
Install gcj with gcc5 on ubunto
Hello,Can you give me installation. Instructions To install gcj after installing gcc5 or gcc6. Apt-get install gcj did not work Thank you very much Envoyé depuis Yahoo Mail pour Android
Re: Install gcj with gcc5 on ubunto
Hello, I have an ubuntu. I installed gcc 5 to be able to install gcj (because gcj is no longer distributed with the new version of gcc).when I run apt-cache search gcj I get this : gcj-5-jdk - GCJ and Classpath development tools for Java(TM) I tried then to install it by running apt-get install gcj-5-jdk, I got this errors: (sorry for the frensh but this means that some packages (listed bellow) could not be installed sudo apt-get install gcj-5-jdk gcj-5-jdk:i386 (5.3.1-14ubuntu2). Vous pouvez lancer « apt --fix-broken install » pour corriger ces problèmes. Les paquets suivants contiennent des dépendances non satisfaites : gcj-5-jdk:i386 : Dépend: gcc-5-base:i386 (= 5.3.1-14ubuntu2) mais ne sera pas installé Dépend: gcc-5:i386 (>= 5.2.1-23) mais ne sera pas installé Dépend: libc6-dev:i386 (>= 2.13-0ubuntu6) mais ne sera pas installé Dépend: gcj-5:i386 (= 5.3.1-14ubuntu2) mais il n'est pas installable Dépend: gcj-5-jre:i386 (= 5.3.1-14ubuntu2) mais il n'est pas installable Dépend: libgcj16-dev:i386 (>= 5.3.1-14ubuntu2) mais il n'est pas installable Dépend: fastjar:i386 Dépend: libgcj-bc:i386 mais il n'est pas installable Dépend: libantlr-java:i386 mais il n'est pas installable Dépend: libc6:i386 (>= 2.4) mais ne sera pas installé Dépend: libgcj16:i386 (>= 5) mais il n'est pas installable Dépend: zlib1g:i386 (>= 1:1.1.4) mais ne sera pas installé Recommande: libecj-java-gcj:i386 mais il n'est pas installable Le lundi 1 juillet 2019 à 10:21:28 UTC+2, Anastasios Lisgaras via gcc-help a écrit : Hello Charfi Asma, What operating system (even - distribution of GNU/Linux) do you work with? Generally, however, in GNU/Linux run : apt-cache search gcj or apt search gcj to find the available packages for your distribution. Try it. I hope I helped you. On 7/1/19 7:20 AM, charfi asma via gcc-help wrote: > Hello,Can you give me installation. Instructions?? > To install gcj after installing gcc5 or gcc6.??Apt-get install gcj did not > work??Thank you very much > Envoy?? depuis Yahoo??Mail pour Android > -- Kind regards, Anastasios Lisgaras z