[LLVM] Infinite loop during LLVM InstructionCombining pass optimization

+llvm-dev [usually it is best to CC the llvm dev list for these kinds
of questions]

Also +David Majnemer for InstCombine.

This looks like an LLVM bug to me if it reproduces on top of tree.
Can you dump out the IR input to InstCombine so that we can reproduce
the infinite loop with `opt -instcombine < bug.ll`? If yes, that
would be a pretty reasonable bug report.

-- Sanjoy

If you're able to reproduce the infinite loop with -O3 then you should
be able to dump out the IR that causes `opt -instcombine` to infloop,
unless the bug is truly esoteric (e.g. only caused by a specific
use-list ordering). Maybe take a closer look at the output from `opt
-print-before-all -O3`?

Alternatively you can use bugpoint to minimize the IR to get a small
reproducer that causes `opt -O3` to hang:
http://blog.llvm.org/2015/11/reduce-your-testcases-with-bugpoint-and.html

-- Sanjoy

Thank you for your guide.

I dumped last IR (input IR to InstCombine pass) into “bug.ll” file by using opt -print-before-all -O3.

I also created bc file using -emit-llvm -O1 -Xclang -disable-llvm-passes -c.

  • you can reproduce the infinite loop by using opt -O2 -instcombine < bug.bc.

I attached these files into this email and please let me know if you need more files and information.

Best Regards,

Y. Jeon.

bug.bc (182 KB)

bug.ll (26.8 KB)

I’ll try to fix this is nobody else has yet. I suspect it’s similar to:
https://reviews.llvm.org/rL333610
…constant expressions get grouped in with regular constants in our pattern matching and cause trouble.

Should be fixed after:
https://reviews.llvm.org/rL365774