[llvm-commits] Possible bug in cost model?

Renato Golin renato.golin at linaro.org
Mon Jan 28 09:14:56 PST 2013


Hi Nadav,

This part of the code seems odd:

  // Check for NOOP conversions.
  if (SrcLT.first == DstLT.first &&
      SrcLT.second.getSizeInBits() == DstLT.second.getSizeInBits()) {

      // Bitcast between types that are legalized to the same type are free.
      if (Opcode == Instruction::BitCast || Opcode == Instruction::Trunc)
        return 0;
  }

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.

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.

Does it make sense?

The attached patch "fixes" this (assuming it's wrong) ;)

cheers,
--renato
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20130128/bc8c23a3/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: cast-cost-bug.patch
Type: application/octet-stream
Size: 1407 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20130128/bc8c23a3/attachment.obj>


More information about the llvm-commits mailing list