summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPatrik Hagglund <patrik.h.hagglund@ericsson.com>2016-06-20 10:19:04 +0000
committerPatrik Hagglund <patrik.h.hagglund@ericsson.com>2016-06-20 10:19:04 +0000
commit96f13afcbc939379520821038ab683410a6c3c05 (patch)
treebc3cbff8595ea600da823e8ac64d8dc1db64ae2d
parenta83706e354705188606bbb857a4d6703c3284d1c (diff)
downloadbcm5719-llvm-96f13afcbc939379520821038ab683410a6c3c05.tar.gz
bcm5719-llvm-96f13afcbc939379520821038ab683410a6c3c05.zip
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
-rw-r--r--llvm/lib/Analysis/ScalarEvolutionExpander.cpp8
1 files changed, 6 insertions, 2 deletions
diff --git a/llvm/lib/Analysis/ScalarEvolutionExpander.cpp b/llvm/lib/Analysis/ScalarEvolutionExpander.cpp
index bcc4381ebf4..77164356d8e 100644
--- a/llvm/lib/Analysis/ScalarEvolutionExpander.cpp
+++ b/llvm/lib/Analysis/ScalarEvolutionExpander.cpp
@@ -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.
OpenPOWER on IntegriCloud