Lines Matching refs:Ops
642 static void GroupByComplexity(SmallVectorImpl<const SCEV *> &Ops, in GroupByComplexity() argument
644 if (Ops.size() < 2) return; // Noop in GroupByComplexity()
645 if (Ops.size() == 2) { in GroupByComplexity()
648 const SCEV *&LHS = Ops[0], *&RHS = Ops[1]; in GroupByComplexity()
655 std::stable_sort(Ops.begin(), Ops.end(), SCEVComplexityCompare(LI)); in GroupByComplexity()
661 for (unsigned i = 0, e = Ops.size(); i != e-2; ++i) { in GroupByComplexity()
662 const SCEV *S = Ops[i]; in GroupByComplexity()
667 for (unsigned j = i+1; j != e && Ops[j]->getSCEVType() == Complexity; ++j) { in GroupByComplexity()
668 if (Ops[j] == S) { // Found a duplicate. in GroupByComplexity()
670 std::swap(Ops[i+1], Ops[j]); in GroupByComplexity()
1809 SmallVector<const SCEV *, 4> Ops; in getAnyExtendExpr() local
1811 Ops.push_back(getAnyExtendExpr(Op, Ty)); in getAnyExtendExpr()
1812 return getAddRecExpr(Ops, AR->getLoop(), SCEV::FlagNW); in getAnyExtendExpr()
1852 const SCEV *const *Ops, size_t NumOperands, in CollectAddOperandsWithScales() argument
1859 while (const SCEVConstant *C = dyn_cast<SCEVConstant>(Ops[i])) { in CollectAddOperandsWithScales()
1870 const SCEVMulExpr *Mul = dyn_cast<SCEVMulExpr>(Ops[i]); in CollectAddOperandsWithScales()
1900 M.insert(std::make_pair(Ops[i], Scale)); in CollectAddOperandsWithScales()
1928 const SmallVectorImpl<const SCEV *> &Ops, in StrengthenNoWrapFlags() argument
1946 std::all_of(Ops.begin(), Ops.end(), IsKnownNonNegative)) in StrengthenNoWrapFlags()
1955 const SCEV *ScalarEvolution::getAddExpr(SmallVectorImpl<const SCEV *> &Ops, in getAddExpr() argument
1959 assert(!Ops.empty() && "Cannot get empty add!"); in getAddExpr()
1960 if (Ops.size() == 1) return Ops[0]; in getAddExpr()
1962 Type *ETy = getEffectiveSCEVType(Ops[0]->getType()); in getAddExpr()
1963 for (unsigned i = 1, e = Ops.size(); i != e; ++i) in getAddExpr()
1964 assert(getEffectiveSCEVType(Ops[i]->getType()) == ETy && in getAddExpr()
1968 Flags = StrengthenNoWrapFlags(this, scAddExpr, Ops, Flags); in getAddExpr()
1971 GroupByComplexity(Ops, LI); in getAddExpr()
1975 if (const SCEVConstant *LHSC = dyn_cast<SCEVConstant>(Ops[0])) { in getAddExpr()
1977 assert(Idx < Ops.size()); in getAddExpr()
1978 while (const SCEVConstant *RHSC = dyn_cast<SCEVConstant>(Ops[Idx])) { in getAddExpr()
1980 Ops[0] = getConstant(LHSC->getValue()->getValue() + in getAddExpr()
1982 if (Ops.size() == 2) return Ops[0]; in getAddExpr()
1983 Ops.erase(Ops.begin()+1); // Erase the folded element in getAddExpr()
1984 LHSC = cast<SCEVConstant>(Ops[0]); in getAddExpr()
1989 Ops.erase(Ops.begin()); in getAddExpr()
1993 if (Ops.size() == 1) return Ops[0]; in getAddExpr()
1999 Type *Ty = Ops[0]->getType(); in getAddExpr()
2001 for (unsigned i = 0, e = Ops.size(); i != e-1; ++i) in getAddExpr()
2002 if (Ops[i] == Ops[i+1]) { // X + Y + Y --> X + Y*2 in getAddExpr()
2005 while (i+Count != e && Ops[i+Count] == Ops[i]) in getAddExpr()
2009 const SCEV *Mul = getMulExpr(Scale, Ops[i]); in getAddExpr()
2010 if (Ops.size() == Count) in getAddExpr()
2012 Ops[i] = Mul; in getAddExpr()
2013 Ops.erase(Ops.begin()+i+1, Ops.begin()+i+Count); in getAddExpr()
2018 return getAddExpr(Ops, Flags); in getAddExpr()
2024 for (; Idx < Ops.size() && isa<SCEVTruncateExpr>(Ops[Idx]); ++Idx) { in getAddExpr()
2025 const SCEVTruncateExpr *Trunc = cast<SCEVTruncateExpr>(Ops[Idx]); in getAddExpr()
2032 for (unsigned i = 0, e = Ops.size(); i != e; ++i) { in getAddExpr()
2033 if (const SCEVTruncateExpr *T = dyn_cast<SCEVTruncateExpr>(Ops[i])) { in getAddExpr()
2039 } else if (const SCEVConstant *C = dyn_cast<SCEVConstant>(Ops[i])) { in getAddExpr()
2041 } else if (const SCEVMulExpr *M = dyn_cast<SCEVMulExpr>(Ops[i])) { in getAddExpr()
2076 while (Idx < Ops.size() && Ops[Idx]->getSCEVType() < scAddExpr) in getAddExpr()
2080 if (Idx < Ops.size()) { in getAddExpr()
2082 while (const SCEVAddExpr *Add = dyn_cast<SCEVAddExpr>(Ops[Idx])) { in getAddExpr()
2085 Ops.erase(Ops.begin()+Idx); in getAddExpr()
2086 Ops.append(Add->op_begin(), Add->op_end()); in getAddExpr()
2094 return getAddExpr(Ops); in getAddExpr()
2098 while (Idx < Ops.size() && Ops[Idx]->getSCEVType() < scMulExpr) in getAddExpr()
2103 if (Idx < Ops.size() && isa<SCEVMulExpr>(Ops[Idx])) { in getAddExpr()
2109 Ops.data(), Ops.size(), in getAddExpr()
2119 Ops.clear(); in getAddExpr()
2121 Ops.push_back(getConstant(AccumulatedConstant)); in getAddExpr()
2125 Ops.push_back(getMulExpr(getConstant(I->first), in getAddExpr()
2127 if (Ops.empty()) in getAddExpr()
2129 if (Ops.size() == 1) in getAddExpr()
2130 return Ops[0]; in getAddExpr()
2131 return getAddExpr(Ops); in getAddExpr()
2138 for (; Idx < Ops.size() && isa<SCEVMulExpr>(Ops[Idx]); ++Idx) { in getAddExpr()
2139 const SCEVMulExpr *Mul = cast<SCEVMulExpr>(Ops[Idx]); in getAddExpr()
2144 for (unsigned AddOp = 0, e = Ops.size(); AddOp != e; ++AddOp) in getAddExpr()
2145 if (MulOpSCEV == Ops[AddOp]) { in getAddExpr()
2159 if (Ops.size() == 2) return OuterMul; in getAddExpr()
2161 Ops.erase(Ops.begin()+AddOp); in getAddExpr()
2162 Ops.erase(Ops.begin()+Idx-1); in getAddExpr()
2164 Ops.erase(Ops.begin()+Idx); in getAddExpr()
2165 Ops.erase(Ops.begin()+AddOp-1); in getAddExpr()
2167 Ops.push_back(OuterMul); in getAddExpr()
2168 return getAddExpr(Ops); in getAddExpr()
2173 OtherMulIdx < Ops.size() && isa<SCEVMulExpr>(Ops[OtherMulIdx]); in getAddExpr()
2175 const SCEVMulExpr *OtherMul = cast<SCEVMulExpr>(Ops[OtherMulIdx]); in getAddExpr()
2198 if (Ops.size() == 2) return OuterMul; in getAddExpr()
2199 Ops.erase(Ops.begin()+Idx); in getAddExpr()
2200 Ops.erase(Ops.begin()+OtherMulIdx-1); in getAddExpr()
2201 Ops.push_back(OuterMul); in getAddExpr()
2202 return getAddExpr(Ops); in getAddExpr()
2211 while (Idx < Ops.size() && Ops[Idx]->getSCEVType() < scAddRecExpr) in getAddExpr()
2215 for (; Idx < Ops.size() && isa<SCEVAddRecExpr>(Ops[Idx]); ++Idx) { in getAddExpr()
2219 const SCEVAddRecExpr *AddRec = cast<SCEVAddRecExpr>(Ops[Idx]); in getAddExpr()
2221 for (unsigned i = 0, e = Ops.size(); i != e; ++i) in getAddExpr()
2222 if (isLoopInvariant(Ops[i], AddRecLoop)) { in getAddExpr()
2223 LIOps.push_back(Ops[i]); in getAddExpr()
2224 Ops.erase(Ops.begin()+i); in getAddExpr()
2244 if (Ops.size() == 1) return NewRec; in getAddExpr()
2248 if (Ops[i] == AddRec) { in getAddExpr()
2249 Ops[i] = NewRec; in getAddExpr()
2252 return getAddExpr(Ops); in getAddExpr()
2259 OtherIdx < Ops.size() && isa<SCEVAddRecExpr>(Ops[OtherIdx]); in getAddExpr()
2261 if (AddRecLoop == cast<SCEVAddRecExpr>(Ops[OtherIdx])->getLoop()) { in getAddExpr()
2265 for (; OtherIdx != Ops.size() && isa<SCEVAddRecExpr>(Ops[OtherIdx]); in getAddExpr()
2268 dyn_cast<SCEVAddRecExpr>(Ops[OtherIdx])) in getAddExpr()
2280 Ops.erase(Ops.begin() + OtherIdx); --OtherIdx; in getAddExpr()
2283 Ops[Idx] = getAddRecExpr(AddRecOps, AddRecLoop, SCEV::FlagAnyWrap); in getAddExpr()
2284 return getAddExpr(Ops); in getAddExpr()
2295 for (unsigned i = 0, e = Ops.size(); i != e; ++i) in getAddExpr()
2296 ID.AddPointer(Ops[i]); in getAddExpr()
2301 const SCEV **O = SCEVAllocator.Allocate<const SCEV *>(Ops.size()); in getAddExpr()
2302 std::uninitialized_copy(Ops.begin(), Ops.end(), O); in getAddExpr()
2304 O, Ops.size()); in getAddExpr()
2346 SmallVector<const SCEV *, 4> Ops; in containsConstantSomewhere() local
2347 Ops.push_back(StartExpr); in containsConstantSomewhere()
2348 while (!Ops.empty()) { in containsConstantSomewhere()
2349 const SCEV *CurrentExpr = Ops.pop_back_val(); in containsConstantSomewhere()
2355 Ops.append(CurrentNAry->op_begin(), CurrentNAry->op_end()); in containsConstantSomewhere()
2363 const SCEV *ScalarEvolution::getMulExpr(SmallVectorImpl<const SCEV *> &Ops, in getMulExpr() argument
2367 assert(!Ops.empty() && "Cannot get empty mul!"); in getMulExpr()
2368 if (Ops.size() == 1) return Ops[0]; in getMulExpr()
2370 Type *ETy = getEffectiveSCEVType(Ops[0]->getType()); in getMulExpr()
2371 for (unsigned i = 1, e = Ops.size(); i != e; ++i) in getMulExpr()
2372 assert(getEffectiveSCEVType(Ops[i]->getType()) == ETy && in getMulExpr()
2376 Flags = StrengthenNoWrapFlags(this, scMulExpr, Ops, Flags); in getMulExpr()
2379 GroupByComplexity(Ops, LI); in getMulExpr()
2383 if (const SCEVConstant *LHSC = dyn_cast<SCEVConstant>(Ops[0])) { in getMulExpr()
2386 if (Ops.size() == 2) in getMulExpr()
2387 if (const SCEVAddExpr *Add = dyn_cast<SCEVAddExpr>(Ops[1])) in getMulExpr()
2396 while (const SCEVConstant *RHSC = dyn_cast<SCEVConstant>(Ops[Idx])) { in getMulExpr()
2401 Ops[0] = getConstant(Fold); in getMulExpr()
2402 Ops.erase(Ops.begin()+1); // Erase the folded element in getMulExpr()
2403 if (Ops.size() == 1) return Ops[0]; in getMulExpr()
2404 LHSC = cast<SCEVConstant>(Ops[0]); in getMulExpr()
2408 if (cast<SCEVConstant>(Ops[0])->getValue()->equalsInt(1)) { in getMulExpr()
2409 Ops.erase(Ops.begin()); in getMulExpr()
2411 } else if (cast<SCEVConstant>(Ops[0])->getValue()->isZero()) { in getMulExpr()
2413 return Ops[0]; in getMulExpr()
2414 } else if (Ops[0]->isAllOnesValue()) { in getMulExpr()
2417 if (Ops.size() == 2) { in getMulExpr()
2418 if (const SCEVAddExpr *Add = dyn_cast<SCEVAddExpr>(Ops[1])) { in getMulExpr()
2423 const SCEV *Mul = getMulExpr(Ops[0], *I); in getMulExpr()
2431 AddRec = dyn_cast<SCEVAddRecExpr>(Ops[1])) { in getMulExpr()
2436 Operands.push_back(getMulExpr(Ops[0], *I)); in getMulExpr()
2444 if (Ops.size() == 1) in getMulExpr()
2445 return Ops[0]; in getMulExpr()
2449 while (Idx < Ops.size() && Ops[Idx]->getSCEVType() < scMulExpr) in getMulExpr()
2453 if (Idx < Ops.size()) { in getMulExpr()
2455 while (const SCEVMulExpr *Mul = dyn_cast<SCEVMulExpr>(Ops[Idx])) { in getMulExpr()
2458 Ops.erase(Ops.begin()+Idx); in getMulExpr()
2459 Ops.append(Mul->op_begin(), Mul->op_end()); in getMulExpr()
2467 return getMulExpr(Ops); in getMulExpr()
2473 while (Idx < Ops.size() && Ops[Idx]->getSCEVType() < scAddRecExpr) in getMulExpr()
2477 for (; Idx < Ops.size() && isa<SCEVAddRecExpr>(Ops[Idx]); ++Idx) { in getMulExpr()
2481 const SCEVAddRecExpr *AddRec = cast<SCEVAddRecExpr>(Ops[Idx]); in getMulExpr()
2483 for (unsigned i = 0, e = Ops.size(); i != e; ++i) in getMulExpr()
2484 if (isLoopInvariant(Ops[i], AddRecLoop)) { in getMulExpr()
2485 LIOps.push_back(Ops[i]); in getMulExpr()
2486 Ops.erase(Ops.begin()+i); in getMulExpr()
2508 if (Ops.size() == 1) return NewRec; in getMulExpr()
2512 if (Ops[i] == AddRec) { in getMulExpr()
2513 Ops[i] = NewRec; in getMulExpr()
2516 return getMulExpr(Ops); in getMulExpr()
2535 OtherIdx != Ops.size() && isa<SCEVAddRecExpr>(Ops[OtherIdx]); in getMulExpr()
2538 dyn_cast<SCEVAddRecExpr>(Ops[OtherIdx]); in getMulExpr()
2571 if (Ops.size() == 2) return NewAddRec; in getMulExpr()
2572 Ops[Idx] = NewAddRec; in getMulExpr()
2573 Ops.erase(Ops.begin() + OtherIdx); --OtherIdx; in getMulExpr()
2581 return getMulExpr(Ops); in getMulExpr()
2591 for (unsigned i = 0, e = Ops.size(); i != e; ++i) in getMulExpr()
2592 ID.AddPointer(Ops[i]); in getMulExpr()
2597 const SCEV **O = SCEVAllocator.Allocate<const SCEV *>(Ops.size()); in getMulExpr()
2598 std::uninitialized_copy(Ops.begin(), Ops.end(), O); in getMulExpr()
2600 O, Ops.size()); in getMulExpr()
2916 SmallVector<const SCEV *, 2> Ops; in getSMaxExpr() local
2917 Ops.push_back(LHS); in getSMaxExpr()
2918 Ops.push_back(RHS); in getSMaxExpr()
2919 return getSMaxExpr(Ops); in getSMaxExpr()
2923 ScalarEvolution::getSMaxExpr(SmallVectorImpl<const SCEV *> &Ops) { in getSMaxExpr() argument
2924 assert(!Ops.empty() && "Cannot get empty smax!"); in getSMaxExpr()
2925 if (Ops.size() == 1) return Ops[0]; in getSMaxExpr()
2927 Type *ETy = getEffectiveSCEVType(Ops[0]->getType()); in getSMaxExpr()
2928 for (unsigned i = 1, e = Ops.size(); i != e; ++i) in getSMaxExpr()
2929 assert(getEffectiveSCEVType(Ops[i]->getType()) == ETy && in getSMaxExpr()
2934 GroupByComplexity(Ops, LI); in getSMaxExpr()
2938 if (const SCEVConstant *LHSC = dyn_cast<SCEVConstant>(Ops[0])) { in getSMaxExpr()
2940 assert(Idx < Ops.size()); in getSMaxExpr()
2941 while (const SCEVConstant *RHSC = dyn_cast<SCEVConstant>(Ops[Idx])) { in getSMaxExpr()
2946 Ops[0] = getConstant(Fold); in getSMaxExpr()
2947 Ops.erase(Ops.begin()+1); // Erase the folded element in getSMaxExpr()
2948 if (Ops.size() == 1) return Ops[0]; in getSMaxExpr()
2949 LHSC = cast<SCEVConstant>(Ops[0]); in getSMaxExpr()
2953 if (cast<SCEVConstant>(Ops[0])->getValue()->isMinValue(true)) { in getSMaxExpr()
2954 Ops.erase(Ops.begin()); in getSMaxExpr()
2956 } else if (cast<SCEVConstant>(Ops[0])->getValue()->isMaxValue(true)) { in getSMaxExpr()
2959 return Ops[0]; in getSMaxExpr()
2962 if (Ops.size() == 1) return Ops[0]; in getSMaxExpr()
2966 while (Idx < Ops.size() && Ops[Idx]->getSCEVType() < scSMaxExpr) in getSMaxExpr()
2971 if (Idx < Ops.size()) { in getSMaxExpr()
2973 while (const SCEVSMaxExpr *SMax = dyn_cast<SCEVSMaxExpr>(Ops[Idx])) { in getSMaxExpr()
2974 Ops.erase(Ops.begin()+Idx); in getSMaxExpr()
2975 Ops.append(SMax->op_begin(), SMax->op_end()); in getSMaxExpr()
2980 return getSMaxExpr(Ops); in getSMaxExpr()
2986 for (unsigned i = 0, e = Ops.size()-1; i != e; ++i) in getSMaxExpr()
2989 if (Ops[i] == Ops[i+1] || in getSMaxExpr()
2990 isKnownPredicate(ICmpInst::ICMP_SGE, Ops[i], Ops[i+1])) { in getSMaxExpr()
2991 Ops.erase(Ops.begin()+i+1, Ops.begin()+i+2); in getSMaxExpr()
2993 } else if (isKnownPredicate(ICmpInst::ICMP_SLE, Ops[i], Ops[i+1])) { in getSMaxExpr()
2994 Ops.erase(Ops.begin()+i, Ops.begin()+i+1); in getSMaxExpr()
2998 if (Ops.size() == 1) return Ops[0]; in getSMaxExpr()
3000 assert(!Ops.empty() && "Reduced smax down to nothing!"); in getSMaxExpr()
3006 for (unsigned i = 0, e = Ops.size(); i != e; ++i) in getSMaxExpr()
3007 ID.AddPointer(Ops[i]); in getSMaxExpr()
3010 const SCEV **O = SCEVAllocator.Allocate<const SCEV *>(Ops.size()); in getSMaxExpr()
3011 std::uninitialized_copy(Ops.begin(), Ops.end(), O); in getSMaxExpr()
3013 O, Ops.size()); in getSMaxExpr()
3020 SmallVector<const SCEV *, 2> Ops; in getUMaxExpr() local
3021 Ops.push_back(LHS); in getUMaxExpr()
3022 Ops.push_back(RHS); in getUMaxExpr()
3023 return getUMaxExpr(Ops); in getUMaxExpr()
3027 ScalarEvolution::getUMaxExpr(SmallVectorImpl<const SCEV *> &Ops) { in getUMaxExpr() argument
3028 assert(!Ops.empty() && "Cannot get empty umax!"); in getUMaxExpr()
3029 if (Ops.size() == 1) return Ops[0]; in getUMaxExpr()
3031 Type *ETy = getEffectiveSCEVType(Ops[0]->getType()); in getUMaxExpr()
3032 for (unsigned i = 1, e = Ops.size(); i != e; ++i) in getUMaxExpr()
3033 assert(getEffectiveSCEVType(Ops[i]->getType()) == ETy && in getUMaxExpr()
3038 GroupByComplexity(Ops, LI); in getUMaxExpr()
3042 if (const SCEVConstant *LHSC = dyn_cast<SCEVConstant>(Ops[0])) { in getUMaxExpr()
3044 assert(Idx < Ops.size()); in getUMaxExpr()
3045 while (const SCEVConstant *RHSC = dyn_cast<SCEVConstant>(Ops[Idx])) { in getUMaxExpr()
3050 Ops[0] = getConstant(Fold); in getUMaxExpr()
3051 Ops.erase(Ops.begin()+1); // Erase the folded element in getUMaxExpr()
3052 if (Ops.size() == 1) return Ops[0]; in getUMaxExpr()
3053 LHSC = cast<SCEVConstant>(Ops[0]); in getUMaxExpr()
3057 if (cast<SCEVConstant>(Ops[0])->getValue()->isMinValue(false)) { in getUMaxExpr()
3058 Ops.erase(Ops.begin()); in getUMaxExpr()
3060 } else if (cast<SCEVConstant>(Ops[0])->getValue()->isMaxValue(false)) { in getUMaxExpr()
3063 return Ops[0]; in getUMaxExpr()
3066 if (Ops.size() == 1) return Ops[0]; in getUMaxExpr()
3070 while (Idx < Ops.size() && Ops[Idx]->getSCEVType() < scUMaxExpr) in getUMaxExpr()
3075 if (Idx < Ops.size()) { in getUMaxExpr()
3077 while (const SCEVUMaxExpr *UMax = dyn_cast<SCEVUMaxExpr>(Ops[Idx])) { in getUMaxExpr()
3078 Ops.erase(Ops.begin()+Idx); in getUMaxExpr()
3079 Ops.append(UMax->op_begin(), UMax->op_end()); in getUMaxExpr()
3084 return getUMaxExpr(Ops); in getUMaxExpr()
3090 for (unsigned i = 0, e = Ops.size()-1; i != e; ++i) in getUMaxExpr()
3093 if (Ops[i] == Ops[i+1] || in getUMaxExpr()
3094 isKnownPredicate(ICmpInst::ICMP_UGE, Ops[i], Ops[i+1])) { in getUMaxExpr()
3095 Ops.erase(Ops.begin()+i+1, Ops.begin()+i+2); in getUMaxExpr()
3097 } else if (isKnownPredicate(ICmpInst::ICMP_ULE, Ops[i], Ops[i+1])) { in getUMaxExpr()
3098 Ops.erase(Ops.begin()+i, Ops.begin()+i+1); in getUMaxExpr()
3102 if (Ops.size() == 1) return Ops[0]; in getUMaxExpr()
3104 assert(!Ops.empty() && "Reduced umax down to nothing!"); in getUMaxExpr()
3110 for (unsigned i = 0, e = Ops.size(); i != e; ++i) in getUMaxExpr()
3111 ID.AddPointer(Ops[i]); in getUMaxExpr()
3114 const SCEV **O = SCEVAllocator.Allocate<const SCEV *>(Ops.size()); in getUMaxExpr()
3115 std::uninitialized_copy(Ops.begin(), Ops.end(), O); in getUMaxExpr()
3117 O, Ops.size()); in getUMaxExpr()
3580 SmallVector<const SCEV *, 8> Ops; in createNodeForPHI() local
3583 Ops.push_back(Add->getOperand(i)); in createNodeForPHI()
3584 const SCEV *Accum = getAddExpr(Ops); in createNodeForPHI()