[llvm-bugs] [Bug 37526] New: [InstCombine] MinMax patterns produce an infinite loop within InstCombine.

via llvm-bugs llvm-bugs at lists.llvm.org
Fri May 18 17:00:34 PDT 2018


https://bugs.llvm.org/show_bug.cgi?id=37526

            Bug ID: 37526
           Summary: [InstCombine] MinMax patterns produce an infinite loop
                    within InstCombine.
           Product: new-bugs
           Version: trunk
          Hardware: PC
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: new bugs
          Assignee: unassignedbugs at nondot.org
          Reporter: matthew.davis at sony.com
                CC: llvm-bugs at lists.llvm.org

Created attachment 20319
  --> https://bugs.llvm.org/attachment.cgi?id=20319&action=edit
Reduced Reproducer

The attached test case is a reduced version of some code that we have found to
be producing an infinite loop within InstCombine.

I have noted that the code works prior to r320157 (December 2017) but with the
added handling of MinMax patterns in the r320157 patch, it seems that
InstCombine::run gets stuck (infinite loop).

In particular, a minmax pattern is discovered in InstCombiner, and
removeBitcastsFromLoadStoreOnMinMax is called (InstCombineLoadStoreAlloca.cpp)
to handle an instruction that matches that pattern.  This routine introduces a
load and store which eventually get removed during the same iteration of
InstCombiner::run(). 
The load becomes trivially dead. The store is removed because it is
automatically added to the Worklist in InstCombiner, and is visited in the same
run() iteration.  When this newly created Store instruction is visited it is
recognized as being part of a minmax pattern, and
removeBitcastsFromLoadStoreOnMinMax is called.  That routine is successful, and
that store is removed.

This instruction add/removal sets the InstCombine::MadeIRChange,  flag which
controls the exit of InstCombine::run.  However, since that iteration of run()
will always add and remove instructions, no fixed point is achieved, and run()
is called indefinitely.

Reproduced with trunk and 6.0 release:
clang++ -O2 ./reducer.cc -c

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20180519/0a9f400c/attachment.html>


More information about the llvm-bugs mailing list