<div dir="ltr">Hi Nadav,<div><br></div><div style>This part of the code seems odd:</div><div style><br></div><div style><div>  // Check for NOOP conversions.</div><div>  if (SrcLT.first == DstLT.first &&</div><div>
      SrcLT.second.getSizeInBits() == DstLT.second.getSizeInBits()) {</div><div><br></div><div>      // Bitcast between types that are legalized to the same type are free.</div><div>      if (Opcode == Instruction::BitCast || Opcode == Instruction::Trunc)</div>
<div>        return 0;</div><div>  }</div><div><br></div><div style>It looks as though it's stating that if the legalization of both types is the same, the cost is zero. I'd assume the cost would be the legalization cost.</div>
<div style><br></div><div style>It may not matter much on most cases because it's an invariant when all paths have the legalization phase, but if one of the paths can avoid the legalization (by completely removing it), than the benefit won't be accounted for.</div>
<div style><br></div><div style>Does it make sense?</div><div style><br></div><div style>The attached patch "fixes" this (assuming it's wrong) ;)</div><div style><br></div><div style>cheers,</div><div style>
--renato</div></div></div>