http://llvm.org/bugs/show_bug.cgi?id=22823

            Bug ID: 22823
           Summary: gvn incorrectly changing sign of floating point zero
           Product: libraries
           Version: 3.6
          Hardware: PC
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: Scalar Optimizations
          Assignee: [email protected]
          Reporter: [email protected]
                CC: [email protected]
    Classification: Unclassified

The following IR essentially corresponds to the statement
  f(x,y) = (x==y & y==0.0) ? y : y+1.0


define double @foo(double, double) {
top:
  %2 = fcmp une double %0, %1
  br i1 %2, label %L3, label %L1

L1:
  %3 = fcmp une double %1, 0.000000e+00
  br i1 %3, label %L3, label %L2

L2:
  ret double %1

L3:
  %4 = fadd double %1, 1.000000e+00
  ret double %4
}


A global value numbering pass incorrectly changes L2 to return the first
argument, which will give the incorrect value when the first argument is 0.0,
and the second is -0.0:

$ bin/opt -S -gvn foo.ll 
; ModuleID = 'foo.ll'

define double @foo(double, double) {
top:
  %2 = fcmp une double %0, %1
  br i1 %2, label %L3, label %L1

L1:                                               ; preds = %top
  %3 = fcmp une double %0, 0.000000e+00
  br i1 %3, label %L3, label %L2

L2:                                               ; preds = %L1
  ret double %0

L3:                                               ; preds = %L1, %top
  %4 = fadd double %1, 1.000000e+00
  ret double %4
}

-- 
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