[llvm-commits] [llvm] r124487 - in /llvm/trunk: include/llvm/Analysis/InstructionSimplify.h lib/Analysis/InstructionSimplify.cpp lib/Transforms/InstCombine/InstCombineMulDivRem.cpp test/Transforms/InstCombine/2008-11-20-DivMulRem.ll test/Transforms/InstSimplify/2010-12-20-Reassociate.ll

Duncan Sands baldrick at free.fr
Sun Jan 30 13:33:22 PST 2011


Hi Evan,

> This broke 254.gap (Darwin, clang, i386 and x86_64).  Please investigate or at least consider backing it out for now.

it looks like 254.gap is incorrectly coded, in that it invokes undefined
behaviour.  Consider the routine AddString for example:

static void     AddString ( str, exp )
     TypSword        * str;
     TypExp          exp;
{
     TypHandle       hd;
     TypExp          e,  * p;

     e = exp * Prime;
#   if USE_SHIFT_TEST
         if ( e / Prime != exp || ((e << 1 ) >> 1) != e )
#else
         if ( e / Prime != exp || e >= MAX_AG_EXP )
#endif
             Error( "Collector: integer overflow (e:%d, str:%d)", e, Prime );
...

It doesn't realise that if the signed multiplication "e = exp * prime"
overflows then the result is undefined and the test e / Prime != exp
can't be relied upon.

There are similar problems in the routines TripleWeight, CombiCollect and
ProdInt, which also explicitly test for integer overflow.

I'm surprised recent gcc doesn't break this too...

Ciao, Duncan.



More information about the llvm-commits mailing list