diff options
author | Dan Gohman <gohman@apple.com> | 2010-04-16 15:03:25 +0000 |
---|---|---|
committer | Dan Gohman <gohman@apple.com> | 2010-04-16 15:03:25 +0000 |
commit | 12293815debf0cf087178f30963f1bd7737b202f (patch) | |
tree | 5661fdc7f8e8afbe955328882cb452d120ff28f5 /llvm/lib/Analysis | |
parent | aa4d9ea4654a2bd4665a9ee3a5670e6cd6b31451 (diff) | |
download | bcm5719-llvm-12293815debf0cf087178f30963f1bd7737b202f.tar.gz bcm5719-llvm-12293815debf0cf087178f30963f1bd7737b202f.zip |
Fix SCEVCommutativeExpr::print to be robust in the case of improper
expression canonicalization. Its job is to print what's there, not to
make judgements about it.
llvm-svn: 101461
Diffstat (limited to 'llvm/lib/Analysis')
-rw-r--r-- | llvm/lib/Analysis/ScalarEvolution.cpp | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/llvm/lib/Analysis/ScalarEvolution.cpp b/llvm/lib/Analysis/ScalarEvolution.cpp index 9e101370d40..14e6bcb1815 100644 --- a/llvm/lib/Analysis/ScalarEvolution.cpp +++ b/llvm/lib/Analysis/ScalarEvolution.cpp @@ -247,11 +247,13 @@ void SCEVSignExtendExpr::print(raw_ostream &OS) const { } void SCEVCommutativeExpr::print(raw_ostream &OS) const { - assert(NumOperands > 1 && "This plus expr shouldn't exist!"); const char *OpStr = getOperationStr(); - OS << "(" << *Operands[0]; - for (unsigned i = 1, e = NumOperands; i != e; ++i) - OS << OpStr << *Operands[i]; + OS << "("; + for (op_iterator I = op_begin(), E = op_end(); I != E; ++I) { + OS << **I; + if (next(I) != E) + OS << OpStr; + } OS << ")"; } |