[llvm-bugs] [Bug 43591] New: sign mismatch for getArithmeticInstrCost() definitions/usage

via llvm-bugs llvm-bugs at lists.llvm.org
Mon Oct 7 10:07:36 PDT 2019


https://bugs.llvm.org/show_bug.cgi?id=43591

            Bug ID: 43591
           Summary: sign mismatch for getArithmeticInstrCost()
                    definitions/usage
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Transformation Utilities
          Assignee: unassignedbugs at nondot.org
          Reporter: spatel+llvm at rotateright.com
                CC: llvm-bugs at lists.llvm.org

Follow-up to bug 43582:

In class TargetTransformInfo::Model final : public TargetTransformInfo::Concept
(in TargetTransformInfo.h), we have:

  /// This is an approximation of reciprocal throughput of a math/logic op.
  /// A higher cost indicates less expected throughput.
  /// From Agner Fog's guides, reciprocal throughput is "the average number of
  /// clock cycles per instruction when the instructions are not part of a
  /// limiting dependency chain."
  /// Therefore, costs should be scaled to account for multiple execution units
  /// on the target that can process this type of instruction. For example, if
  /// there are 5 scalar integer units and 2 vector integer units that can
  /// calculate an 'add' in a single cycle, this model should indicate that the
  /// cost of the vector add instruction is 2.5 times the cost of the scalar
  /// add instruction.
  /// \p Args is an optional argument which holds the instruction operands
  /// values so the TTI can analyze those values searching for special
  /// cases or optimizations based on those values.
  int getArithmeticInstrCost(
      unsigned Opcode, Type *Ty, OperandValueKind Opd1Info = OK_AnyValue,
      OperandValueKind Opd2Info = OK_AnyValue,
      OperandValueProperties Opd1PropInfo = OP_None,
      OperandValueProperties Opd2PropInfo = OP_None,
      ArrayRef<const Value *> Args = ArrayRef<const Value *>()) const;


In class BasicTTIImplBase : public TargetTransformInfoImplCRTPBase<T> (in
BasicTTIImpl.h), we have:

  unsigned getArithmeticInstrCost(
      unsigned Opcode, Type *Ty,
      TTI::OperandValueKind Opd1Info = TTI::OK_AnyValue,
      TTI::OperandValueKind Opd2Info = TTI::OK_AnyValue,
      TTI::OperandValueProperties Opd1PropInfo = TTI::OP_None,
      TTI::OperandValueProperties Opd2PropInfo = TTI::OP_None,
      ArrayRef<const Value *> Args = ArrayRef<const Value *>()) {

----------------------------------------------------------------------------

We're returning a signed value in the first function even though a reciprocal
throughput shouldn't ever be negative. The LoopVectorizer assumes the value is
unsigned. The SLPVectorizer uses these values to compare relative perf and uses
subtraction of signed values when comparing scalar and vector sequences. 

Both of these interpretations can't be right?

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20191007/fa414b27/attachment.html>


More information about the llvm-bugs mailing list