[LLVMbugs] [Bug 19237] New: ISel DAG: HandleMergeInputChains is overly conservative

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Mon Mar 24 14:05:43 PDT 2014


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

            Bug ID: 19237
           Summary: ISel DAG: HandleMergeInputChains is overly
                    conservative
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: Common Code Generator Code
          Assignee: unassignedbugs at nondot.org
          Reporter: qcolombet at apple.com
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified

Created attachment 12277
  --> http://llvm.org/bugs/attachment.cgi?id=12277&action=edit
Testcase that show a missed folding because of the overly conservative check

During the select phase of the isel process, SelectionDAGISel performs a check
to see if a load is foldable into another node (for node supporting that
feature of course).
In particular, it checks that folding the load into the related node will not
create a cycle in the DAG.
This check is done by HandleMergeInputChains.

HandleMergeInputChains is not actually checking that a cycle will be created if
something is folded into something else.
In particular, it is not checking for reachability but instead relies on
heuristics to give a quick answer. This answer is conservatively correct:
- No: no cycle will be created.
- Yes: a cycle *may* be created.

I believe this limitation is intended for three reasons:
1. to avoid costly reachability checks.
2. to handle only the rewriting of token factor from the not-yet-matched nodes
to the matched node.
3. everything that has been matched is ready to schedule.

The risk with this approximation is twofold:
- The lowering phase may rely on this folding to happen. As a result "cannot
select" cases may happen like what we fixed in r204631.
- Although this may not impact the performance, the generated code looks bad,
and the code size is impacted.

* STEPS TO REPRODUCE
llc -mattr=+avx2 testcase.ll -o - -O3

* RESULTS
The fallback pattern is used for the broadcast instruction:
    movb    (%rdi), %al
    vmovd    %eax, %xmm1
    vpbroadcastb    %xmm1, %xmm1
Whereas the folding pattern would have match if the cycle detection was
correct:
    vpbroadcastb    (%rdi), %xmm1

-- 
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/20140324/91de0a67/attachment.html>


More information about the llvm-bugs mailing list