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: [email protected]
          Reporter: [email protected]
                CC: [email protected]
    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.
_______________________________________________
LLVMbugs mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/llvmbugs

Reply via email to