[LLVMbugs] [Bug 16164] New: Cannonicalize B * (uitofp i1 C)=?UTF-8?Q?=20=E2=80=94?=> select C, B, 0

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Tue May 28 08:27:02 PDT 2013


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

            Bug ID: 16164
           Summary: Cannonicalize B * (uitofp i1 C) —> select C, B, 0
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: Backend: X86
          Assignee: unassignedbugs at nondot.org
          Reporter: jduprat at apple.com
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified

I initially introduced the following inst combines in r181216:
B * (uitofp i1 C) —> select C, B, 0
A * (1 - uitofp i1 C) —> select C, 0, A
select C, 0, B + select C, A, 0 —> select C, A, B

Together these 3 changes would simplify:
A * (1 - uitofp i1 C) + B * uitofp i1 C 
down to :
select C, B, A

It was found that converting the multiplies to selects would hurt performance
on platforms with an FMA instruction where the mul would have been essentially
free.
Change r181216 thus removed the first two inst combines and instead introduced
the following transformations:

select C, B, 0 + select C, 0, A —> select C, B, A
A * (1 - uitofp i1 C) + B * uitofp i1 C —> select C, B, A

This resolves the immediate performance problem, but it is felt that the select
form is a better canonical representation of what is going on, and should
eventually be reintroduced.

Pros:
- Unambiguously represents what is going on
- Reduces users of the conversion
- Will with vectorization

Cons:
- Can prevent formation of FMAs
- The multiply will perform better than the conditional select on some ISAs

We need to address the cons in the various backends (at least ARM, ARM64 and
x86) before re-enabling the above cannonicalization.  We can then remove the
following inst combine, as it will no longer be necessary:
A * (1 - uitofp i1 C) + B * uitofp i1 C —> select C, B, A

-- 
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/20130528/21b537cf/attachment.html>


More information about the llvm-bugs mailing list