[llvm-commits] [llvm] r69294 - /llvm/trunk/lib/Analysis/ScalarEvolutionExpander.cpp

Dan Gohman gohman at apple.com
Thu Apr 16 09:15:27 PDT 2009


Author: djg
Date: Thu Apr 16 11:15:25 2009
New Revision: 69294

URL: http://llvm.org/viewvc/llvm-project?rev=69294&view=rev
Log:
Fix SCEVExpander::visitSMaxExpr and SCEVExpander::visitUMaxExpr to
not create ICmpInsts with operands of different types. This fixes
a regression in Applications/d/make_dparser.

Modified:
    llvm/trunk/lib/Analysis/ScalarEvolutionExpander.cpp

Modified: llvm/trunk/lib/Analysis/ScalarEvolutionExpander.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/ScalarEvolutionExpander.cpp?rev=69294&r1=69293&r2=69294&view=diff

==============================================================================
--- llvm/trunk/lib/Analysis/ScalarEvolutionExpander.cpp (original)
+++ llvm/trunk/lib/Analysis/ScalarEvolutionExpander.cpp Thu Apr 16 11:15:25 2009
@@ -295,9 +295,13 @@
 }
 
 Value *SCEVExpander::visitSMaxExpr(SCEVSMaxExpr *S) {
+  const Type *Ty = S->getType();
   Value *LHS = expand(S->getOperand(0));
+  LHS = InsertCastOfTo(CastInst::getCastOpcode(LHS, false, Ty, false), LHS, Ty);
   for (unsigned i = 1; i < S->getNumOperands(); ++i) {
     Value *RHS = expand(S->getOperand(i));
+    RHS = InsertCastOfTo(CastInst::getCastOpcode(RHS, false, Ty, false),
+                         RHS, Ty);
     Value *ICmp = new ICmpInst(ICmpInst::ICMP_SGT, LHS, RHS, "tmp", InsertPt);
     LHS = SelectInst::Create(ICmp, LHS, RHS, "smax", InsertPt);
   }
@@ -305,9 +309,13 @@
 }
 
 Value *SCEVExpander::visitUMaxExpr(SCEVUMaxExpr *S) {
+  const Type *Ty = S->getType();
   Value *LHS = expand(S->getOperand(0));
+  LHS = InsertCastOfTo(CastInst::getCastOpcode(LHS, false, Ty, false), LHS, Ty);
   for (unsigned i = 1; i < S->getNumOperands(); ++i) {
     Value *RHS = expand(S->getOperand(i));
+    RHS = InsertCastOfTo(CastInst::getCastOpcode(RHS, false, Ty, false),
+                         RHS, Ty);
     Value *ICmp = new ICmpInst(ICmpInst::ICMP_UGT, LHS, RHS, "tmp", InsertPt);
     LHS = SelectInst::Create(ICmp, LHS, RHS, "umax", InsertPt);
   }





More information about the llvm-commits mailing list