[llvm-bugs] [Bug 28296] New: [InstCombine] unary operations are assigned the wrong complexity

via llvm-bugs llvm-bugs at lists.llvm.org
Fri Jun 24 12:16:28 PDT 2016


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

            Bug ID: 28296
           Summary: [InstCombine] unary operations are assigned the wrong
                    complexity
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: Scalar Optimizations
          Assignee: unassignedbugs at nondot.org
          Reporter: spatel+llvm at rotateright.com
                CC: llvm-bugs at lists.llvm.org
    Classification: Unclassified

I noticed this while figuring out how InstCombine's commutation transforms work
for http://reviews.llvm.org/rL273702:

/// \brief Assign a complexity or rank value to LLVM Values.
///
/// This routine maps IR values to various complexity ranks:
///   0 -> undef
///   1 -> Constants
///   2 -> Other non-instructions
///   3 -> Arguments
///   3 -> Unary operations
///   4 -> Other instructions
static inline unsigned getComplexity(Value *V) {
  if (isa<Instruction>(V)) {
    if (BinaryOperator::isNeg(V) || BinaryOperator::isFNeg(V) ||
        BinaryOperator::isNot(V))
      return 3;
    return 4;
  }
  if (isa<Argument>(V))
    return 3;
  return isa<Constant>(V) ? (isa<UndefValue>(V) ? 0 : 1) : 2;
}

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

The logic doesn't match the comments: only fake binary operators (neg/not/fneg)
are assigned complexity of 3. Actual unary operators like cast instructions get
complexity 4.

-- 
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/20160624/446dc2c3/attachment.html>


More information about the llvm-bugs mailing list