Avoid output indeterminism between GCC and Clang builds.

Remove dependency of the evalution order of function arguments, which
is unspecified.

Patch by David Stenberg.

llvm-svn: 273145
This commit is contained in:
Patrik Hagglund 2016-06-20 10:19:04 +00:00
parent a83706e354
commit 96f13afcbc
1 changed files with 6 additions and 2 deletions

View File

@ -1443,8 +1443,12 @@ Value *SCEVExpander::visitAddRecExpr(const SCEVAddRecExpr *S) {
}
// Just do a normal add. Pre-expand the operands to suppress folding.
return expand(SE.getAddExpr(SE.getUnknown(expand(S->getStart())),
SE.getUnknown(expand(Rest))));
//
// The LHS and RHS values are factored out of the expand call to make the
// output independent of the argument evaluation order.
const SCEV *AddExprLHS = SE.getUnknown(expand(S->getStart()));
const SCEV *AddExprRHS = SE.getUnknown(expand(Rest));
return expand(SE.getAddExpr(AddExprLHS, AddExprRHS));
}
// If we don't yet have a canonical IV, create one.