diff --git a/llvm/lib/Analysis/ScalarEvolution.cpp b/llvm/lib/Analysis/ScalarEvolution.cpp index 4d7def2e4d0e..85f9794aa8d8 100644 --- a/llvm/lib/Analysis/ScalarEvolution.cpp +++ b/llvm/lib/Analysis/ScalarEvolution.cpp @@ -6389,15 +6389,8 @@ const SCEV *ScalarEvolution::createSCEV(Value *V) { if (GetMinTrailingZeros(LHS) >= (CIVal.getBitWidth() - CIVal.countLeadingZeros())) { // Build a plain add SCEV. - const SCEV *S = getAddExpr(LHS, getSCEV(CI)); - // If the LHS of the add was an addrec and it has no-wrap flags, - // transfer the no-wrap flags, since an or won't introduce a wrap. - if (const SCEVAddRecExpr *NewAR = dyn_cast(S)) { - const SCEVAddRecExpr *OldAR = cast(LHS); - const_cast(NewAR)->setNoWrapFlags( - OldAR->getNoWrapFlags()); - } - return S; + return getAddExpr(LHS, getSCEV(CI), + (SCEV::NoWrapFlags)(SCEV::FlagNUW | SCEV::FlagNSW)); } } break;