On Tue, Jan 15, 2019 at 2:18 PM Frank Tetzel <s1445...@mail.zih.tu-dresden.de> wrote: > > Hi, > > why is the ICF pass in gcc not folding member functions which depend on > a template parameter but happen to generate identical code? > Is it because it is not identical on the IR level in the compiler? > Can I somehow dump the IR in text form?
You can look at the ICF dump generated when you pass -fdump-ipa-icf-details And yes, ICF has to consider IL differences that may result in different allowed followup optimizations while when the IL is final (such as link-time) no such considerations have to be made. A very simple example would be signed vs. unsigned integer multiplication where from the former IL overflow would be undefined and optimizations can exploit that while not for the latter. > The ICF pass in the gold linker can do it on binary level which is kind > of mentioned in manpage of gcc. I'm just interested in why the compiler > cannot do it on its own. > > There is a test program in a blog post I wrote [1]. > > Best regards, > Frank > > [1] > https://tetzank.github.io/posts/identical-code-folding/#consolidating-independent-member-functions