1 //===--------- SCEVAffinator.cpp - Create Scops from LLVM IR -------------===// 2 // 3 // The LLVM Compiler Infrastructure 4 // 5 // This file is distributed under the University of Illinois Open Source 6 // License. See LICENSE.TXT for details. 7 // 8 //===----------------------------------------------------------------------===// 9 // 10 // Create a polyhedral description for a SCEV value. 11 // 12 //===----------------------------------------------------------------------===// 13 14 #include "polly/Support/SCEVAffinator.h" 15 #include "polly/Options.h" 16 #include "polly/ScopInfo.h" 17 #include "polly/Support/GICHelper.h" 18 #include "polly/Support/ISLOperators.h" 19 #include "polly/Support/SCEVValidator.h" 20 #include "polly/Support/ScopHelper.h" 21 #include "isl/aff.h" 22 #include "isl/local_space.h" 23 #include "isl/set.h" 24 #include "isl/val.h" 25 26 using namespace llvm; 27 using namespace polly; 28 29 static cl::opt<bool> IgnoreIntegerWrapping( 30 "polly-ignore-integer-wrapping", 31 cl::desc("Do not build run-time checks to proof absence of integer " 32 "wrapping"), 33 cl::Hidden, cl::ZeroOrMore, cl::init(false), cl::cat(PollyCategory)); 34 35 // The maximal number of basic sets we allow during the construction of a 36 // piecewise affine function. More complex ones will result in very high 37 // compile time. 38 static int const MaxDisjunctionsInPwAff = 100; 39 40 // The maximal number of bits for which a general expression is modeled 41 // precisely. 42 static unsigned const MaxSmallBitWidth = 7; 43 44 /// Add the number of basic sets in @p Domain to @p User 45 static isl_stat addNumBasicSets(__isl_take isl_set *Domain, 46 __isl_take isl_aff *Aff, void *User) { 47 auto *NumBasicSets = static_cast<unsigned *>(User); 48 *NumBasicSets += isl_set_n_basic_set(Domain); 49 isl_set_free(Domain); 50 isl_aff_free(Aff); 51 return isl_stat_ok; 52 } 53 54 /// Determine if @p PWAC is too complex to continue. 55 static bool isTooComplex(PWACtx PWAC) { 56 unsigned NumBasicSets = 0; 57 isl_pw_aff_foreach_piece(PWAC.first.keep(), addNumBasicSets, &NumBasicSets); 58 if (NumBasicSets <= MaxDisjunctionsInPwAff) 59 return false; 60 return true; 61 } 62 63 /// Return the flag describing the possible wrapping of @p Expr. 64 static SCEV::NoWrapFlags getNoWrapFlags(const SCEV *Expr) { 65 if (auto *NAry = dyn_cast<SCEVNAryExpr>(Expr)) 66 return NAry->getNoWrapFlags(); 67 return SCEV::NoWrapMask; 68 } 69 70 static PWACtx combine(PWACtx PWAC0, PWACtx PWAC1, 71 __isl_give isl_pw_aff *(Fn)(__isl_take isl_pw_aff *, 72 __isl_take isl_pw_aff *)) { 73 PWAC0.first = isl::manage(Fn(PWAC0.first.take(), PWAC1.first.take())); 74 PWAC0.second = PWAC0.second.unite(PWAC1.second); 75 return PWAC0; 76 } 77 78 static __isl_give isl_pw_aff *getWidthExpValOnDomain(unsigned Width, 79 __isl_take isl_set *Dom) { 80 auto *Ctx = isl_set_get_ctx(Dom); 81 auto *WidthVal = isl_val_int_from_ui(Ctx, Width); 82 auto *ExpVal = isl_val_2exp(WidthVal); 83 return isl_pw_aff_val_on_domain(Dom, ExpVal); 84 } 85 86 SCEVAffinator::SCEVAffinator(Scop *S, LoopInfo &LI) 87 : S(S), Ctx(S->getIslCtx().get()), SE(*S->getSE()), LI(LI), 88 TD(S->getFunction().getParent()->getDataLayout()) {} 89 90 Loop *SCEVAffinator::getScope() { return BB ? LI.getLoopFor(BB) : nullptr; } 91 92 void SCEVAffinator::interpretAsUnsigned(PWACtx &PWAC, unsigned Width) { 93 auto *NonNegDom = isl_pw_aff_nonneg_set(PWAC.first.copy()); 94 auto *NonNegPWA = 95 isl_pw_aff_intersect_domain(PWAC.first.copy(), isl_set_copy(NonNegDom)); 96 auto *ExpPWA = getWidthExpValOnDomain(Width, isl_set_complement(NonNegDom)); 97 PWAC.first = isl::manage(isl_pw_aff_union_add( 98 NonNegPWA, isl_pw_aff_add(PWAC.first.take(), ExpPWA))); 99 } 100 101 void SCEVAffinator::takeNonNegativeAssumption(PWACtx &PWAC) { 102 auto *NegPWA = isl_pw_aff_neg(PWAC.first.copy()); 103 auto *NegDom = isl_pw_aff_pos_set(NegPWA); 104 PWAC.second = 105 isl::manage(isl_set_union(PWAC.second.take(), isl_set_copy(NegDom))); 106 auto *Restriction = BB ? NegDom : isl_set_params(NegDom); 107 auto DL = BB ? BB->getTerminator()->getDebugLoc() : DebugLoc(); 108 S->recordAssumption(UNSIGNED, isl::manage(Restriction), DL, AS_RESTRICTION, 109 BB); 110 } 111 112 PWACtx SCEVAffinator::getPWACtxFromPWA(isl::pw_aff PWA) { 113 return std::make_pair(PWA, isl::set::empty(isl::space(Ctx, 0, NumIterators))); 114 } 115 116 PWACtx SCEVAffinator::getPwAff(const SCEV *Expr, BasicBlock *BB) { 117 this->BB = BB; 118 119 if (BB) { 120 auto *DC = S->getDomainConditions(BB).release(); 121 NumIterators = isl_set_n_dim(DC); 122 isl_set_free(DC); 123 } else 124 NumIterators = 0; 125 126 return visit(Expr); 127 } 128 129 PWACtx SCEVAffinator::checkForWrapping(const SCEV *Expr, PWACtx PWAC) const { 130 // If the SCEV flags do contain NSW (no signed wrap) then PWA already 131 // represents Expr in modulo semantic (it is not allowed to overflow), thus we 132 // are done. Otherwise, we will compute: 133 // PWA = ((PWA + 2^(n-1)) mod (2 ^ n)) - 2^(n-1) 134 // whereas n is the number of bits of the Expr, hence: 135 // n = bitwidth(ExprType) 136 137 if (IgnoreIntegerWrapping || (getNoWrapFlags(Expr) & SCEV::FlagNSW)) 138 return PWAC; 139 140 isl::pw_aff PWAMod = addModuloSemantic(PWAC.first, Expr->getType()); 141 142 isl::set NotEqualSet = PWAC.first.ne_set(PWAMod); 143 PWAC.second = PWAC.second.unite(NotEqualSet).coalesce(); 144 145 const DebugLoc &Loc = BB ? BB->getTerminator()->getDebugLoc() : DebugLoc(); 146 if (!BB) 147 NotEqualSet = NotEqualSet.params(); 148 NotEqualSet = NotEqualSet.coalesce(); 149 150 if (!NotEqualSet.is_empty()) 151 S->recordAssumption(WRAPPING, NotEqualSet, Loc, AS_RESTRICTION, BB); 152 153 return PWAC; 154 } 155 156 isl::pw_aff SCEVAffinator::addModuloSemantic(isl::pw_aff PWA, 157 Type *ExprType) const { 158 unsigned Width = TD.getTypeSizeInBits(ExprType); 159 160 auto ModVal = isl::val::int_from_ui(Ctx, Width); 161 ModVal = ModVal.two_exp(); 162 163 isl::set Domain = PWA.domain(); 164 isl::pw_aff AddPW = 165 isl::manage(getWidthExpValOnDomain(Width - 1, Domain.take())); 166 167 return PWA.add(AddPW).mod(ModVal).sub(AddPW); 168 } 169 170 bool SCEVAffinator::hasNSWAddRecForLoop(Loop *L) const { 171 for (const auto &CachedPair : CachedExpressions) { 172 auto *AddRec = dyn_cast<SCEVAddRecExpr>(CachedPair.first.first); 173 if (!AddRec) 174 continue; 175 if (AddRec->getLoop() != L) 176 continue; 177 if (AddRec->getNoWrapFlags() & SCEV::FlagNSW) 178 return true; 179 } 180 181 return false; 182 } 183 184 bool SCEVAffinator::computeModuloForExpr(const SCEV *Expr) { 185 unsigned Width = TD.getTypeSizeInBits(Expr->getType()); 186 // We assume nsw expressions never overflow. 187 if (auto *NAry = dyn_cast<SCEVNAryExpr>(Expr)) 188 if (NAry->getNoWrapFlags() & SCEV::FlagNSW) 189 return false; 190 return Width <= MaxSmallBitWidth; 191 } 192 193 PWACtx SCEVAffinator::visit(const SCEV *Expr) { 194 195 auto Key = std::make_pair(Expr, BB); 196 PWACtx PWAC = CachedExpressions[Key]; 197 if (PWAC.first) 198 return PWAC; 199 200 auto ConstantAndLeftOverPair = extractConstantFactor(Expr, SE); 201 auto *Factor = ConstantAndLeftOverPair.first; 202 Expr = ConstantAndLeftOverPair.second; 203 204 auto *Scope = getScope(); 205 S->addParams(getParamsInAffineExpr(&S->getRegion(), Scope, Expr, SE)); 206 207 // In case the scev is a valid parameter, we do not further analyze this 208 // expression, but create a new parameter in the isl_pw_aff. This allows us 209 // to treat subexpressions that we cannot translate into an piecewise affine 210 // expression, as constant parameters of the piecewise affine expression. 211 if (isl_id *Id = S->getIdForParam(Expr).release()) { 212 isl_space *Space = isl_space_set_alloc(Ctx.get(), 1, NumIterators); 213 Space = isl_space_set_dim_id(Space, isl_dim_param, 0, Id); 214 215 isl_set *Domain = isl_set_universe(isl_space_copy(Space)); 216 isl_aff *Affine = isl_aff_zero_on_domain(isl_local_space_from_space(Space)); 217 Affine = isl_aff_add_coefficient_si(Affine, isl_dim_param, 0, 1); 218 219 PWAC = getPWACtxFromPWA(isl::manage(isl_pw_aff_alloc(Domain, Affine))); 220 } else { 221 PWAC = SCEVVisitor<SCEVAffinator, PWACtx>::visit(Expr); 222 if (computeModuloForExpr(Expr)) 223 PWAC.first = addModuloSemantic(PWAC.first, Expr->getType()); 224 else 225 PWAC = checkForWrapping(Expr, PWAC); 226 } 227 228 if (!Factor->getType()->isIntegerTy(1)) { 229 PWAC = combine(PWAC, visitConstant(Factor), isl_pw_aff_mul); 230 if (computeModuloForExpr(Key.first)) 231 PWAC.first = addModuloSemantic(PWAC.first, Expr->getType()); 232 } 233 234 // For compile time reasons we need to simplify the PWAC before we cache and 235 // return it. 236 PWAC.first = PWAC.first.coalesce(); 237 if (!computeModuloForExpr(Key.first)) 238 PWAC = checkForWrapping(Key.first, PWAC); 239 240 CachedExpressions[Key] = PWAC; 241 return PWAC; 242 } 243 244 PWACtx SCEVAffinator::visitConstant(const SCEVConstant *Expr) { 245 ConstantInt *Value = Expr->getValue(); 246 isl_val *v; 247 248 // LLVM does not define if an integer value is interpreted as a signed or 249 // unsigned value. Hence, without further information, it is unknown how 250 // this value needs to be converted to GMP. At the moment, we only support 251 // signed operations. So we just interpret it as signed. Later, there are 252 // two options: 253 // 254 // 1. We always interpret any value as signed and convert the values on 255 // demand. 256 // 2. We pass down the signedness of the calculation and use it to interpret 257 // this constant correctly. 258 v = isl_valFromAPInt(Ctx.get(), Value->getValue(), /* isSigned */ true); 259 260 isl_space *Space = isl_space_set_alloc(Ctx.get(), 0, NumIterators); 261 isl_local_space *ls = isl_local_space_from_space(Space); 262 return getPWACtxFromPWA( 263 isl::manage(isl_pw_aff_from_aff(isl_aff_val_on_domain(ls, v)))); 264 } 265 266 PWACtx SCEVAffinator::visitTruncateExpr(const SCEVTruncateExpr *Expr) { 267 // Truncate operations are basically modulo operations, thus we can 268 // model them that way. However, for large types we assume the operand 269 // to fit in the new type size instead of introducing a modulo with a very 270 // large constant. 271 272 auto *Op = Expr->getOperand(); 273 auto OpPWAC = visit(Op); 274 275 unsigned Width = TD.getTypeSizeInBits(Expr->getType()); 276 277 if (computeModuloForExpr(Expr)) 278 return OpPWAC; 279 280 auto *Dom = OpPWAC.first.domain().take(); 281 auto *ExpPWA = getWidthExpValOnDomain(Width - 1, Dom); 282 auto *GreaterDom = 283 isl_pw_aff_ge_set(OpPWAC.first.copy(), isl_pw_aff_copy(ExpPWA)); 284 auto *SmallerDom = 285 isl_pw_aff_lt_set(OpPWAC.first.copy(), isl_pw_aff_neg(ExpPWA)); 286 auto *OutOfBoundsDom = isl_set_union(SmallerDom, GreaterDom); 287 OpPWAC.second = OpPWAC.second.unite(isl::manage_copy(OutOfBoundsDom)); 288 289 if (!BB) { 290 assert(isl_set_dim(OutOfBoundsDom, isl_dim_set) == 0 && 291 "Expected a zero dimensional set for non-basic-block domains"); 292 OutOfBoundsDom = isl_set_params(OutOfBoundsDom); 293 } 294 295 S->recordAssumption(UNSIGNED, isl::manage(OutOfBoundsDom), DebugLoc(), 296 AS_RESTRICTION, BB); 297 298 return OpPWAC; 299 } 300 301 PWACtx SCEVAffinator::visitZeroExtendExpr(const SCEVZeroExtendExpr *Expr) { 302 // A zero-extended value can be interpreted as a piecewise defined signed 303 // value. If the value was non-negative it stays the same, otherwise it 304 // is the sum of the original value and 2^n where n is the bit-width of 305 // the original (or operand) type. Examples: 306 // zext i8 127 to i32 -> { [127] } 307 // zext i8 -1 to i32 -> { [256 + (-1)] } = { [255] } 308 // zext i8 %v to i32 -> [v] -> { [v] | v >= 0; [256 + v] | v < 0 } 309 // 310 // However, LLVM/Scalar Evolution uses zero-extend (potentially lead by a 311 // truncate) to represent some forms of modulo computation. The left-hand side 312 // of the condition in the code below would result in the SCEV 313 // "zext i1 <false, +, true>for.body" which is just another description 314 // of the C expression "i & 1 != 0" or, equivalently, "i % 2 != 0". 315 // 316 // for (i = 0; i < N; i++) 317 // if (i & 1 != 0 /* == i % 2 */) 318 // /* do something */ 319 // 320 // If we do not make the modulo explicit but only use the mechanism described 321 // above we will get the very restrictive assumption "N < 3", because for all 322 // values of N >= 3 the SCEVAddRecExpr operand of the zero-extend would wrap. 323 // Alternatively, we can make the modulo in the operand explicit in the 324 // resulting piecewise function and thereby avoid the assumption on N. For the 325 // example this would result in the following piecewise affine function: 326 // { [i0] -> [(1)] : 2*floor((-1 + i0)/2) = -1 + i0; 327 // [i0] -> [(0)] : 2*floor((i0)/2) = i0 } 328 // To this end we can first determine if the (immediate) operand of the 329 // zero-extend can wrap and, in case it might, we will use explicit modulo 330 // semantic to compute the result instead of emitting non-wrapping 331 // assumptions. 332 // 333 // Note that operands with large bit-widths are less likely to be negative 334 // because it would result in a very large access offset or loop bound after 335 // the zero-extend. To this end one can optimistically assume the operand to 336 // be positive and avoid the piecewise definition if the bit-width is bigger 337 // than some threshold (here MaxZextSmallBitWidth). 338 // 339 // We choose to go with a hybrid solution of all modeling techniques described 340 // above. For small bit-widths (up to MaxZextSmallBitWidth) we will model the 341 // wrapping explicitly and use a piecewise defined function. However, if the 342 // bit-width is bigger than MaxZextSmallBitWidth we will employ overflow 343 // assumptions and assume the "former negative" piece will not exist. 344 345 auto *Op = Expr->getOperand(); 346 auto OpPWAC = visit(Op); 347 348 // If the width is to big we assume the negative part does not occur. 349 if (!computeModuloForExpr(Op)) { 350 takeNonNegativeAssumption(OpPWAC); 351 return OpPWAC; 352 } 353 354 // If the width is small build the piece for the non-negative part and 355 // the one for the negative part and unify them. 356 unsigned Width = TD.getTypeSizeInBits(Op->getType()); 357 interpretAsUnsigned(OpPWAC, Width); 358 return OpPWAC; 359 } 360 361 PWACtx SCEVAffinator::visitSignExtendExpr(const SCEVSignExtendExpr *Expr) { 362 // As all values are represented as signed, a sign extension is a noop. 363 return visit(Expr->getOperand()); 364 } 365 366 PWACtx SCEVAffinator::visitAddExpr(const SCEVAddExpr *Expr) { 367 PWACtx Sum = visit(Expr->getOperand(0)); 368 369 for (int i = 1, e = Expr->getNumOperands(); i < e; ++i) { 370 Sum = combine(Sum, visit(Expr->getOperand(i)), isl_pw_aff_add); 371 if (isTooComplex(Sum)) 372 return std::make_pair(nullptr, nullptr); 373 } 374 375 return Sum; 376 } 377 378 PWACtx SCEVAffinator::visitMulExpr(const SCEVMulExpr *Expr) { 379 PWACtx Prod = visit(Expr->getOperand(0)); 380 381 for (int i = 1, e = Expr->getNumOperands(); i < e; ++i) { 382 Prod = combine(Prod, visit(Expr->getOperand(i)), isl_pw_aff_mul); 383 if (isTooComplex(Prod)) 384 return std::make_pair(nullptr, nullptr); 385 } 386 387 return Prod; 388 } 389 390 PWACtx SCEVAffinator::visitAddRecExpr(const SCEVAddRecExpr *Expr) { 391 assert(Expr->isAffine() && "Only affine AddRecurrences allowed"); 392 393 auto Flags = Expr->getNoWrapFlags(); 394 395 // Directly generate isl_pw_aff for Expr if 'start' is zero. 396 if (Expr->getStart()->isZero()) { 397 assert(S->contains(Expr->getLoop()) && 398 "Scop does not contain the loop referenced in this AddRec"); 399 400 PWACtx Step = visit(Expr->getOperand(1)); 401 isl_space *Space = isl_space_set_alloc(Ctx.get(), 0, NumIterators); 402 isl_local_space *LocalSpace = isl_local_space_from_space(Space); 403 404 unsigned loopDimension = S->getRelativeLoopDepth(Expr->getLoop()); 405 406 isl_aff *LAff = isl_aff_set_coefficient_si( 407 isl_aff_zero_on_domain(LocalSpace), isl_dim_in, loopDimension, 1); 408 isl_pw_aff *LPwAff = isl_pw_aff_from_aff(LAff); 409 410 Step.first = Step.first.mul(isl::manage(LPwAff)); 411 return Step; 412 } 413 414 // Translate AddRecExpr from '{start, +, inc}' into 'start + {0, +, inc}' 415 // if 'start' is not zero. 416 // TODO: Using the original SCEV no-wrap flags is not always safe, however 417 // as our code generation is reordering the expression anyway it doesn't 418 // really matter. 419 const SCEV *ZeroStartExpr = 420 SE.getAddRecExpr(SE.getConstant(Expr->getStart()->getType(), 0), 421 Expr->getStepRecurrence(SE), Expr->getLoop(), Flags); 422 423 PWACtx Result = visit(ZeroStartExpr); 424 PWACtx Start = visit(Expr->getStart()); 425 Result = combine(Result, Start, isl_pw_aff_add); 426 return Result; 427 } 428 429 PWACtx SCEVAffinator::visitSMaxExpr(const SCEVSMaxExpr *Expr) { 430 PWACtx Max = visit(Expr->getOperand(0)); 431 432 for (int i = 1, e = Expr->getNumOperands(); i < e; ++i) { 433 Max = combine(Max, visit(Expr->getOperand(i)), isl_pw_aff_max); 434 if (isTooComplex(Max)) 435 return std::make_pair(nullptr, nullptr); 436 } 437 438 return Max; 439 } 440 441 PWACtx SCEVAffinator::visitUMaxExpr(const SCEVUMaxExpr *Expr) { 442 llvm_unreachable("SCEVUMaxExpr not yet supported"); 443 } 444 445 PWACtx SCEVAffinator::visitUDivExpr(const SCEVUDivExpr *Expr) { 446 // The handling of unsigned division is basically the same as for signed 447 // division, except the interpretation of the operands. As the divisor 448 // has to be constant in both cases we can simply interpret it as an 449 // unsigned value without additional complexity in the representation. 450 // For the dividend we could choose from the different representation 451 // schemes introduced for zero-extend operations but for now we will 452 // simply use an assumption. 453 auto *Dividend = Expr->getLHS(); 454 auto *Divisor = Expr->getRHS(); 455 assert(isa<SCEVConstant>(Divisor) && 456 "UDiv is no parameter but has a non-constant RHS."); 457 458 auto DividendPWAC = visit(Dividend); 459 auto DivisorPWAC = visit(Divisor); 460 461 if (SE.isKnownNegative(Divisor)) { 462 // Interpret negative divisors unsigned. This is a special case of the 463 // piece-wise defined value described for zero-extends as we already know 464 // the actual value of the constant divisor. 465 unsigned Width = TD.getTypeSizeInBits(Expr->getType()); 466 auto *DivisorDom = DivisorPWAC.first.domain().take(); 467 auto *WidthExpPWA = getWidthExpValOnDomain(Width, DivisorDom); 468 DivisorPWAC.first = DivisorPWAC.first.add(isl::manage(WidthExpPWA)); 469 } 470 471 // TODO: One can represent the dividend as piece-wise function to be more 472 // precise but therefor a heuristic is needed. 473 474 // Assume a non-negative dividend. 475 takeNonNegativeAssumption(DividendPWAC); 476 477 DividendPWAC = combine(DividendPWAC, DivisorPWAC, isl_pw_aff_div); 478 DividendPWAC.first = DividendPWAC.first.floor(); 479 480 return DividendPWAC; 481 } 482 483 PWACtx SCEVAffinator::visitSDivInstruction(Instruction *SDiv) { 484 assert(SDiv->getOpcode() == Instruction::SDiv && "Assumed SDiv instruction!"); 485 486 auto *Scope = getScope(); 487 auto *Divisor = SDiv->getOperand(1); 488 auto *DivisorSCEV = SE.getSCEVAtScope(Divisor, Scope); 489 auto DivisorPWAC = visit(DivisorSCEV); 490 assert(isa<SCEVConstant>(DivisorSCEV) && 491 "SDiv is no parameter but has a non-constant RHS."); 492 493 auto *Dividend = SDiv->getOperand(0); 494 auto *DividendSCEV = SE.getSCEVAtScope(Dividend, Scope); 495 auto DividendPWAC = visit(DividendSCEV); 496 DividendPWAC = combine(DividendPWAC, DivisorPWAC, isl_pw_aff_tdiv_q); 497 return DividendPWAC; 498 } 499 500 PWACtx SCEVAffinator::visitSRemInstruction(Instruction *SRem) { 501 assert(SRem->getOpcode() == Instruction::SRem && "Assumed SRem instruction!"); 502 503 auto *Scope = getScope(); 504 auto *Divisor = SRem->getOperand(1); 505 auto *DivisorSCEV = SE.getSCEVAtScope(Divisor, Scope); 506 auto DivisorPWAC = visit(DivisorSCEV); 507 assert(isa<ConstantInt>(Divisor) && 508 "SRem is no parameter but has a non-constant RHS."); 509 510 auto *Dividend = SRem->getOperand(0); 511 auto *DividendSCEV = SE.getSCEVAtScope(Dividend, Scope); 512 auto DividendPWAC = visit(DividendSCEV); 513 DividendPWAC = combine(DividendPWAC, DivisorPWAC, isl_pw_aff_tdiv_r); 514 return DividendPWAC; 515 } 516 517 PWACtx SCEVAffinator::visitUnknown(const SCEVUnknown *Expr) { 518 if (Instruction *I = dyn_cast<Instruction>(Expr->getValue())) { 519 switch (I->getOpcode()) { 520 case Instruction::IntToPtr: 521 return visit(SE.getSCEVAtScope(I->getOperand(0), getScope())); 522 case Instruction::PtrToInt: 523 return visit(SE.getSCEVAtScope(I->getOperand(0), getScope())); 524 case Instruction::SDiv: 525 return visitSDivInstruction(I); 526 case Instruction::SRem: 527 return visitSRemInstruction(I); 528 default: 529 break; // Fall through. 530 } 531 } 532 533 llvm_unreachable( 534 "Unknowns SCEV was neither parameter nor a valid instruction."); 535 } 536