[LLVMbugs] [Bug 23926] New: Reassociate wrongly preserves nuw

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Tue Jun 23 05:13:58 PDT 2015


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

            Bug ID: 23926
           Summary: Reassociate wrongly preserves nuw
           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 bug.ll
define i2 @func78000101(i2, i2) {
  %3 = add nuw i2 %0, 1
  %4 = sub nuw nsw i2 %1, %3
  ret i2 %4
}


$ opt -reassociate -S bug.ll
define i2 @func78000101(i2, i2) {
  %.neg = sub i2 0, %0
  %.neg1 = add nuw i2 %.neg, -1
  %3 = add i2 %.neg1, %1
  ret i2 %3
}


$ ./alive.py bug.opt
----------------------------------------
Optimization: func78000101
Precondition: true
  %3 = add nuw i2 %0, 1
  %4 = sub nuw nsw i2 %1, %3
  ret i2 %4
=>
  %.neg = sub i2 0, %0
  %.neg1 = add nuw i2 %.neg, -1
  %3 = add i2 %.neg1, %1
  ret i2 %3


ERROR: Domain of undefinedness of Target is smaller than Source's for i2 %3

Example:
%0 i2 = 0x2 (2, -2)
%1 i2 = 0x0 (0)
%.neg i2 = 0x2 (2, -2)
%.neg1 i2 = 0x1 (1)
Undef inputs: %1
Source value: 0x3 (3, -1)
Target value: undef

-- 
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/20150623/a2fb1e55/attachment.html>


More information about the llvm-bugs mailing list