[LLVMbugs] [Bug 21610] New: Different IR if intermediate variable used for fcmp + select

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Wed Nov 19 12:48:15 PST 2014


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

            Bug ID: 21610
           Summary: Different IR if intermediate variable used for fcmp +
                    select
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: Scalar Optimizations
          Assignee: unassignedbugs at nondot.org
          Reporter: Matthew.Arsenault at amd.com
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified

I expect these 2 functions to produce the same optimized IR, but they currently
end up using a different fcmp type.


float max_uge_f32_0(float a, float b)
{
    bool cmp = !(a < b);
    return cmp ? b : a;
}

float max_uge_f32_2(float a, float b)
{
    return !(a < b) ? b : a;
}


clang -O3 for this produces:


define float @max_uge_f32_0(float %a, float %b) #0 {
  %1 = fcmp uge float %a, %b
  %2 = select i1 %1, float %b, float %a
  ret float %2
}

define float @max_uge_f32_2(float %a, float %b) #0 {
  %1 = fcmp olt float %a, %b
  %2 = select i1 %1, float %a, float %b
  ret float %2
}

I expect the second's results for the first, swapping the select operands and
using the ordered comparison. However, the first version is using the original
select order with the unordered compare.

-- 
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/20141119/20a210ee/attachment.html>


More information about the llvm-bugs mailing list