From 4d1c1efd800727165c12c2d186a5cb0b4f5834ab Mon Sep 17 00:00:00 2001 From: Dan Gohman Date: Fri, 19 Jun 2009 23:03:46 +0000 Subject: [PATCH] Fix LSR's OptimizeSMax to ignore max operators with more than 2 operands, which it isn't prepared to handle. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@73787 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Transforms/Scalar/LoopStrengthReduce.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/Transforms/Scalar/LoopStrengthReduce.cpp b/lib/Transforms/Scalar/LoopStrengthReduce.cpp index 03966672d62..dac734029b4 100644 --- a/lib/Transforms/Scalar/LoopStrengthReduce.cpp +++ b/lib/Transforms/Scalar/LoopStrengthReduce.cpp @@ -2116,6 +2116,11 @@ ICmpInst *LoopStrengthReduce::OptimizeSMax(Loop *L, ICmpInst *Cond, const SCEVSMaxExpr *SMax = dyn_cast(IterationCount); if (!SMax || SMax != SE->getSCEV(Sel)) return Cond; + // Two handle a max with more than two operands, this optimization would + // require additional checking and setup. + if (SMax->getNumOperands() != 2) + return Cond; + SCEVHandle SMaxLHS = SMax->getOperand(0); SCEVHandle SMaxRHS = SMax->getOperand(1); if (!SMaxLHS || SMaxLHS != One) return Cond;