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

            Bug ID: 23038
           Summary: float2int miscompile
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: Scalar Optimizations
          Assignee: [email protected]
          Reporter: [email protected]
                CC: [email protected]
    Classification: Unclassified

Created attachment 14106
  --> https://llvm.org/bugs/attachment.cgi?id=14106&action=edit
C testcase

opt -float2int transforms this:

define i32 @test(i8 %call) {
  %conv1 = sitofp i8 %call to float
  %mul = fmul float %conv1, -3.000000e+00
  %conv2 = fptosi float %mul to i8
  %conv3 = sext i8 %conv2 to i32
  ret i32 %conv3
}

into this:

define i32 @test(i8 %call) {
  %1 = sext i8 %call to i32
  %mul1 = mul i32 %1, 0  ;; XXX nope
  %2 = trunc i32 %mul1 to i8
  %conv3 = sext i8 %2 to i32
  ret i32 %conv3
}

See attached .cc testcase that fails with "clang -O2 -fno-inline" (by printing
"0 -27 0" when it should print "-27 -27 1").

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