The killloop-branch produces wrong code for the following test due to a bug in
loop-invariant.c or code related to it.

extern "C" void abort(void);
class runtime_error {};
void test01(int iters)
{
    for (int i = 0;   i < iters;   ++i)
    {
        try  {
            throw runtime_error();
            abort();
        } catch (runtime_error&) {  }
    }
}

int main(int argc, char* argv[])
{
    test01(1);
    return 0;
}

The problem is that the following expression is moved out of the loop:

(insn 64 63 54 3 (set (reg:DI 350)
        (reg:DI 16 r16)) 5 {*movdi_internal} (nil)
    (nil))

See the attached dumps.  So far I can only reproduce the bug on IA-64. 
Obviously, exceptions are involved somehow.  On ia64, there are also over 300
libjava failures that disappear when loop-invariant.c is disabled.


-- 
           Summary: [killloop-branch] code motion of non-invariant
                    expressions with hard registers.
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Keywords: wrong-code
          Severity: normal
          Priority: P3
         Component: rtl-optimization
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: steven at gcc dot gnu dot org
GCC target triplet: ia64


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=24762

Reply via email to