Today the front-ends (llvm-gcc and clang) generate multiple llvm.dbg.compile_units...
[oota-llvm.git] / lib / Analysis / ScalarEvolutionExpander.cpp
index 30df087cef3e8bf42f1af09477366fd8cbf76658..211f013c25c49f8577521a010eafc27e795ae21a 100644 (file)
@@ -143,6 +143,15 @@ Value *SCEVExpander::visitUDivExpr(SCEVUDivExpr *S) {
   return InsertBinop(Instruction::UDiv, LHS, RHS, InsertPt);
 }
 
+Value *SCEVExpander::visitSDivExpr(SCEVSDivExpr *S) {
+  // Do not fold sdiv into ashr, unless you know that LHS is positive. On
+  // negative values, it rounds the wrong way.
+
+  Value *LHS = expand(S->getLHS());
+  Value *RHS = expand(S->getRHS());
+  return InsertBinop(Instruction::SDiv, LHS, RHS, InsertPt);
+}
+
 Value *SCEVExpander::visitAddRecExpr(SCEVAddRecExpr *S) {
   const Type *Ty = S->getType();
   const Loop *L = S->getLoop();