[llvm-commits] [llvm] r122716 - in /llvm/trunk: lib/Transforms/Scalar/EarlyCSE.cpp lib/Transforms/Scalar/LoopIdiomRecognize.cpp test/Transforms/EarlyCSE/basic.ll

Frits van Bommel fvbommel at gmail.com
Sun Jan 2 16:02:16 PST 2011


On Mon, Jan 3, 2011 at 12:19 AM, Chris Lattner <sabre at nondot.org> wrote:
> +  else if (GetElementPtrInst *GEP = dyn_cast<GetElementPtrInst>(Inst)) {
> +    Res = getHash(CI->getOperand(0));
> +    for (unsigned i = 1, e = GEP->getNumOperands(); i != e; ++i)
> +      Res ^= getHash(CI->getOperand(i)) << i;
> +  } else if (CmpInst *CI = dyn_cast<CmpInst>(Inst)) {
> +      Res = getHash(CI->getOperand(0)) ^ (getHash(CI->getOperand(1)) << 1) ^
> +         CI->getPredicate();
> +  } else {
> +    assert((isa<SelectInst>(Inst) || isa<ExtractElementInst>(Inst) ||
> +            isa<InsertElementInst>(Inst) || isa<ShuffleVectorInst>(Inst) ||
> +            isa<ExtractValueInst>(Inst) || isa<InsertValueInst>(Inst)) &&
> +           "Unhandled instruction kind");
> +    Res = getHash(CI->getType()) << 4;
> +    for (unsigned i = 0, e = Inst->getNumOperands(); i != e; ++i)
> +      Res ^= getHash(CI->getOperand(i)) << i;
> +  }

ExtractValue/InsertValue indices aren't operands, so they're not taken
into account here.

Also, it might make sense to simplify the code by handling operands
more generically instead of duplicating the code in each if clause.

> +// This could regognize common matrix multiplies and dot product idioms and
> +// replace them with calls to BLAS (if linked in??).

s/regognize/recognize/




More information about the llvm-commits mailing list