From 8ca5b2a6d2a599161500c8403bc95823beebf877 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Wed, 24 Aug 2005 17:55:32 +0000 Subject: [PATCH] Fix Regression/Transforms/Reassociate/2005-08-24-Crash.ll llvm-svn: 23019 --- llvm/lib/Transforms/Scalar/Reassociate.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/llvm/lib/Transforms/Scalar/Reassociate.cpp b/llvm/lib/Transforms/Scalar/Reassociate.cpp index c55bce0d7e8c..60722ef68ffb 100644 --- a/llvm/lib/Transforms/Scalar/Reassociate.cpp +++ b/llvm/lib/Transforms/Scalar/Reassociate.cpp @@ -496,9 +496,15 @@ void Reassociate::OptimizeExpression(unsigned Opcode, ++NumAnnihil; } else { assert(Opcode == Instruction::Xor); + if (e == 2) { + Ops[0].Op = Constant::getNullValue(Ops[0].Op->getType()); + Ops.erase(Ops.begin()+1, Ops.end()); + ++NumAnnihil; + return; + } // ... X^X -> ... Ops.erase(Ops.begin()+i, Ops.begin()+i+2); - i -= 2; e -= 2; + i -= 1; e -= 2; IterateOptimization = true; ++NumAnnihil; }