From 4db3581a288dcd7e56f0a1ecdc2316cd85e183c7 Mon Sep 17 00:00:00 2001 From: Dan Gohman Date: Fri, 9 Oct 2009 00:41:22 +0000 Subject: [PATCH] Preserve HasNSW and HasNUW when constructing SCEVs for Add and Mul instructions. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@83606 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Analysis/ScalarEvolution.cpp | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/lib/Analysis/ScalarEvolution.cpp b/lib/Analysis/ScalarEvolution.cpp index 9300de11685..bdf31f9a706 100644 --- a/lib/Analysis/ScalarEvolution.cpp +++ b/lib/Analysis/ScalarEvolution.cpp @@ -2951,12 +2951,20 @@ const SCEV *ScalarEvolution::createSCEV(Value *V) { Operator *U = cast(V); switch (Opcode) { - case Instruction::Add: + case Instruction::Add: { + AddOperator *A = cast(U); return getAddExpr(getSCEV(U->getOperand(0)), - getSCEV(U->getOperand(1))); - case Instruction::Mul: + getSCEV(U->getOperand(1)), + A->hasNoUnsignedWrap(), + A->hasNoSignedWrap()); + } + case Instruction::Mul: { + MulOperator *M = cast(U); return getMulExpr(getSCEV(U->getOperand(0)), - getSCEV(U->getOperand(1))); + getSCEV(U->getOperand(1)), + M->hasNoUnsignedWrap(), + M->hasNoSignedWrap()); + } case Instruction::UDiv: return getUDivExpr(getSCEV(U->getOperand(0)), getSCEV(U->getOperand(1))); -- 2.34.1