[LLVMdev] Confuse on getSCEVAtScope

ether zhhb etherzhhb at gmail.com
Tue Jun 29 07:08:12 PDT 2010

hi all,

i have SCEVAddRec

{{(32 + @edge.8265),+,32}<Loop0>,+,4}<Loop1>

where Loop0 and Loop1 are brothers (loops at the same level of the
loopnest), and Loop0 have a computable backedge taken count.

when i call getSCEVAtScope({{(32 +
@edge.8265),+,32}<Loop0>,+,4}<Loop1> , Loop1), it just give me  a
{{(32 + @edge.8265),+,32}<Loop0>,+,4}<Loop1>,
 instead of {some_value, + ,4}<loop0>, where some_value is
getSCEVAtScope({(32 + @edge.8265),+,32}<Loop0>, Loop1). because Loop0
have a computable backedge taken count, some_value should not be a

and later i have a look computeSCEVAtScope, and see the function do
not do any thing when AddRec->getLoop()->contains(L).
why  computeSCEVAtScope not try to get the operands in the current
scope like the function do with SCEVCommutativeExpr, like:

if (const SCEVAddRecExpr *AddRec = dyn_cast<SCEVAddRecExpr>(V)) {
    if (!L || !AddRec->getLoop()->contains(L)) {
      // Then, evaluate the AddRec.
      AddRec = AddRec->evaluateAtIteration(BackedgeTakenCount, *this);

    try to evalue every operand of AddRec;

    return AddRec;

thanks very much.
best regards

More information about the llvm-dev mailing list