[llvm-bugs] [Bug 43143] New: [InstCombine] SimplifyAssociativeOrCommutative - dodgy NSW transform checks

via llvm-bugs llvm-bugs at lists.llvm.org
Wed Aug 28 08:40:14 PDT 2019


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

            Bug ID: 43143
           Summary: [InstCombine] SimplifyAssociativeOrCommutative - dodgy
                    NSW transform checks
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Scalar Optimizations
          Assignee: unassignedbugs at nondot.org
          Reporter: llvm-dev at redking.me.uk
                CC: llvm-bugs at lists.llvm.org, Matthew.Arsenault at amd.com,
                    spatel+llvm at rotateright.com

The following code in InstructionCombining.cpp ~line 345 needs reviewing and
cleaning up:

if (IsNSW &&
    (!Op0 || (isa<BinaryOperator>(Op0) && Op0->hasNoSignedWrap()))) {
  // Note: this is only valid because SimplifyBinOp doesn't look at
  // the operands to Op0.
  I.setHasNoSignedWrap(true);
}

1 - Op0 came from dyn_cast<BinaryOperator>(I.getOperand(0)), and an outer if()
has already confirmed that its not null.

2 - Op0->hasNoSignedWrap does a cast<OverflowingBinaryOperator> which we're not
checking for.

I only noticed in passing as cppcheck warned that the !Op0 should be redundant.

-- 
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/20190828/ebf5d684/attachment.html>


More information about the llvm-bugs mailing list