<div class="gmail_quote">2009/6/12 Frits van Bommel <span dir="ltr"><<a href="mailto:fvbommel@wxs.nl">fvbommel@wxs.nl</a>></span><br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">

<div><div></div><div class="h5">Nick Lewycky wrote:<br>
> +  // Check special state that is a part of some instructions.<br>
> +  if (const LoadInst *LI = dyn_cast<LoadInst>(I1))<br>
> +    return LI->isVolatile() == cast<LoadInst>(I2)->isVolatile() &&<br>
> +           LI->getAlignment() == cast<LoadInst>(I2)->getAlignment();<br>
> +  if (const StoreInst *SI = dyn_cast<StoreInst>(I1))<br>
> +    return SI->isVolatile() == cast<StoreInst>(I2)->isVolatile() &&<br>
> +           SI->getAlignment() == cast<StoreInst>(I2)->getAlignment();<br>
> +  if (const CmpInst *CI = dyn_cast<CmpInst>(I1))<br>
> +    return CI->getPredicate() == cast<CmpInst>(I2)->getPredicate();<br>
> +  if (const CallInst *CI = dyn_cast<CallInst>(I1))<br>
> +    return CI->isTailCall() == cast<CallInst>(I2)->isTailCall() &&<br>
> +           CI->getCallingConv() == cast<CallInst>(I2)->getCallingConv() &&<br>
> +           CI->getAttributes().getRawPointer() ==<br>
> +             cast<CallInst>(I2)->getAttributes().getRawPointer();<br>
> +  if (const InvokeInst *CI = dyn_cast<InvokeInst>(I1))<br>
> +    return CI->getCallingConv() == cast<InvokeInst>(I2)->getCallingConv() &&<br>
> +           CI->getAttributes().getRawPointer() ==<br>
> +             cast<InvokeInst>(I2)->getAttributes().getRawPointer();<br>
> +  if (const InsertValueInst *IVI = dyn_cast<InsertValueInst>(I1)) {<br>
> +    if (IVI->getNumIndices() != cast<InsertValueInst>(I2)->getNumIndices())<br>
> +      return false;<br>
> +    for (unsigned i = 0, e = IVI->getNumIndices(); i != e; ++i)<br>
> +      if (IVI->idx_begin()[i] != cast<InsertValueInst>(I2)->idx_begin()[i])<br>
> +        return false;<br>
> +    return true;<br>
> +  }<br>
> +  if (const ExtractValueInst *EVI = dyn_cast<ExtractValueInst>(I1)) {<br>
> +    if (EVI->getNumIndices() != cast<ExtractValueInst>(I2)->getNumIndices())<br>
> +      return false;<br>
> +    for (unsigned i = 0, e = EVI->getNumIndices(); i != e; ++i)<br>
> +      if (EVI->idx_begin()[i] != cast<ExtractValueInst>(I2)->idx_begin()[i])<br>
> +        return false;<br>
> +    return true;<br>
> +  }<br>
> +<br>
> +  return true;<br>
>  }<br>
<br>
</div></div>Shouldn't this have some special handling of GEPs too? A "gep {i32, i8}* %arg,<br>
i32 0, i32 1" is a different operation than "gep {i8, i8}* %arg, i32 0, i32 1"<br>
even though the types of the first operands (which are both pointers) are<br>
"equivalent".<br>
(Merging GEPs should probably require that the type *pointed at* by their first<br>
operands are equivalent)</blockquote><div><br>Yes, you're right. Thanks again for doing review! Comparing the elements that come before the offset being computed is the right fix, but I'd have to think a bit about how to implement that.<br>

<br>MergeFunctions is not on by default but if someone is relying on it a really quick fix would be to check for GEP and then compare real Type* of the first operand instead of looking at the equivalence.<br><br>Nick</div>

</div><br>