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

            Bug ID: 23922
           Summary: GVN incorrectly propagates exact attribute
           Product: libraries
           Version: trunk
          Hardware: All
                OS: All
            Status: NEW
          Keywords: miscompilation
          Severity: normal
          Priority: P
         Component: Scalar Optimizations
          Assignee: [email protected]
          Reporter: [email protected]
                CC: [email protected], [email protected],
                    [email protected]
    Classification: Unclassified

$ cat bug.ll
define i2 @func16731728(i2, i1, i4, i2, i1, i4, i2, i1, i4, i2, i1, i4) {
  %13 = sdiv exact i2 %0, -2
  %14 = sdiv i2 %0, -2
  %15 = select i1 %1, i2 %13, i2 %14
  ret i2 %15
}


$ opt -gvn -S bug.ll

define i2 @func16731728(i2, i1, i4, i2, i1, i4, i2, i1, i4, i2, i1, i4) {
  %13 = sdiv exact i2 %0, -2
  ret i2 %13
}


This is wrong if we assume that select only propagates poison/undef through the
dynamically chosen value  (which I believe is the current interpretation of how
select works).


$ ./alive.py gvn.opt
----------------------------------------
Optimization: func16731728
Precondition: true
  %13 = sdiv exact i2 %0, -2
  %14 = sdiv i2 %0, -2
  %15 = select i1 %1, i2 %13, i2 %14
=>
  %15 = sdiv exact i2 %0, -2


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

Example:
%0 i2 = 0x3 (3, -1)
%1 i1 = 0x0 (0)
%13 i2 = 0x0 (0)
%14 i2 = 0x0 (0)
Source value: 0x0 (0)
Target value: undef

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
LLVMbugs mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/llvmbugs

Reply via email to