[PATCH] SCEV incorrectly marks certain expressions as nsw

hfinkel at anl.gov hfinkel at anl.gov
Mon Feb 16 02:15:55 PST 2015

Indeed, that call site seems inconsistent with the stated precondition of getPreStartForSignExtend. Not only do we not prove NSW there before calling getSignExtendAddRecStart (which calls getPreStartForSignExtend), but in all cases where we could prove NSW on AR, we return prior to reaching that callsite.

However, is this the right fix? The condition you're checking is a stated pre-condition of the function. Is this the only dependence on that pre-condition? Maybe we should add an assert, and a check in the caller?

Comment at: lib/Analysis/ScalarEvolution.cpp:1397
@@ -1396,3 +1396,3 @@
       const_cast<SCEVAddRecExpr *>(PreAR)->setNoWrapFlags(SCEV::FlagNSW);
     // FIXME: this optimization needs a unit test
     DEBUG(dbgs() << "SCEV: untested prestart overflow check\n");
Can you run the test suite or self hosting with an assert here and see if you can find a test case?

Otherwise, we're just ++(technical dept);



More information about the llvm-commits mailing list