[LLVMbugs] [Bug 23675] New: Reassociate wrongly preserves nsw in mul->mul transform

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Wed May 27 05:52:47 PDT 2015


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

            Bug ID: 23675
           Summary: Reassociate wrongly preserves nsw in mul->mul
                    transform
           Product: libraries
           Version: trunk
          Hardware: All
                OS: All
            Status: NEW
          Keywords: miscompilation
          Severity: normal
          Priority: P
         Component: Scalar Optimizations
          Assignee: unassignedbugs at nondot.org
          Reporter: nunoplopes at sapo.pt
                CC: david.majnemer at gmail.com, llvmbugs at cs.uiuc.edu,
                    regehr at cs.utah.edu
    Classification: Unclassified

$ cat a.ll
define i4 @func1821422(i2, i1, i4, i2, i1, i4, i2, i1, i4, i2, i1, i4) {
  %13 = mul nsw i4 -2, %2
  %14 = add i4 %13, 3
  ret i4 %14
}


$ opt -S -reassociate a.ll
define i4 @func1821422(i2, i1, i4, i2, i1, i4, i2, i1, i4, i2, i1, i4) {
  %13 = mul nsw i4 %2, 2
  %14 = sub i4 3, %13
  ret i4 %14
}


$ alive.py b.opt
----------------------------------------
Optimization: 1
Precondition: true
  %13 = mul nsw i4 -2, %2
  %14 = add i4 %13, 3
  ret i4 %14
=>
  %p13 = mul nsw i4 %2, 2
  %p14 = sub i4 3, %p13
  ret i4 %p14


ERROR: Domain of poisoness of Target is smaller than Source's for i4 ret_

Example:
%2 i4 = 0x4 (4)
%13 i4 = 0x8 (8, -8)
%14 i4 = 0xB (11, -5)
%p13 i4 = 0x8 (8, -8)
%p14 i4 = 0xB (11, -5)
Source value: 0xB (11, -5)
Target value: poison

-- 
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/20150527/99f4e9af/attachment.html>


More information about the llvm-bugs mailing list