2015-09-24 15:22:38 +08:00
|
|
|
; REQUIRES: asserts
|
2017-08-02 08:28:10 +08:00
|
|
|
; RUN: llc -mtriple=x86_64-unknown-linux-gnu < %s | FileCheck -check-prefix=X86 %s
|
2017-10-14 00:13:23 +08:00
|
|
|
; RUN: llc -mtriple=x86_64-unknown-linux-gnu -debug-only=isel < %s -o /dev/null 2>&1 | FileCheck -check-prefix=DBGDAG %s
|
2015-09-24 15:22:38 +08:00
|
|
|
|
|
|
|
; It's OK to merge the load / store of the first 2 components, but
|
|
|
|
; they must not be placed on the same chain after merging.
|
|
|
|
|
|
|
|
; X86-LABEL: {{^}}merge_store_partial_overlap_load:
|
2016-04-09 02:58:29 +08:00
|
|
|
; X86-DAG: movzwl ([[BASEREG:%[a-z]+]]), %e[[LO2:[a-z]+]]
|
2015-09-24 15:22:38 +08:00
|
|
|
; X86-DAG: movb 2([[BASEREG]]), [[HI1:%[a-z]+]]
|
|
|
|
|
2016-04-09 02:58:29 +08:00
|
|
|
; X86-NEXT: movw %[[LO2]], 1([[BASEREG]])
|
2015-09-24 15:22:38 +08:00
|
|
|
; X86-NEXT: movb [[HI1]], 3([[BASEREG]])
|
|
|
|
; X86-NEXT: retq
|
|
|
|
|
2017-12-05 01:18:51 +08:00
|
|
|
; DBGDAG-LABEL: Optimized legalized selection DAG: %bb.0 'merge_store_partial_overlap_load:'
|
2015-09-24 15:22:38 +08:00
|
|
|
; DBGDAG: [[ENTRYTOKEN:t[0-9]+]]: ch = EntryToken
|
|
|
|
; DBGDAG-DAG: [[BASEPTR:t[0-9]+]]: i64,ch = CopyFromReg [[ENTRYTOKEN]],
|
2017-10-14 01:00:49 +08:00
|
|
|
; DBGDAG-DAG: [[ADDPTR:t[0-9]+]]: i64 = add {{(nuw )?}}[[BASEPTR]], Constant:i64<2>
|
2015-09-24 15:22:38 +08:00
|
|
|
|
2018-03-15 05:52:13 +08:00
|
|
|
; DBGDAG-DAG: [[LD2:t[0-9]+]]: i16,ch = load<(load 2 from %ir.tmp81, align 1)> [[ENTRYTOKEN]], [[BASEPTR]], undef:i64
|
|
|
|
; DBGDAG-DAG: [[LD1:t[0-9]+]]: i8,ch = load<(load 1 from %ir.tmp12)> [[ENTRYTOKEN]], [[ADDPTR]], undef:i64
|
2015-09-24 15:22:38 +08:00
|
|
|
|
2018-03-15 05:52:13 +08:00
|
|
|
; DBGDAG-DAG: [[ST1:t[0-9]+]]: ch = store<(store 1 into %ir.tmp14)> [[ENTRYTOKEN]], [[LD1]], t{{[0-9]+}}, undef:i64
|
In visitSTORE, always use FindBetterChain, rather than only when UseAA is enabled.
Recommiting with compiler time improvements
Recommitting after fixup of 32-bit aliasing sign offset bug in DAGCombiner.
* Simplify Consecutive Merge Store Candidate Search
Now that address aliasing is much less conservative, push through
simplified store merging search and chain alias analysis which only
checks for parallel stores through the chain subgraph. This is cleaner
as the separation of non-interfering loads/stores from the
store-merging logic.
When merging stores search up the chain through a single load, and
finds all possible stores by looking down from through a load and a
TokenFactor to all stores visited.
This improves the quality of the output SelectionDAG and the output
Codegen (save perhaps for some ARM cases where we correctly constructs
wider loads, but then promotes them to float operations which appear
but requires more expensive constant generation).
Some minor peephole optimizations to deal with improved SubDAG shapes (listed below)
Additional Minor Changes:
1. Finishes removing unused AliasLoad code
2. Unifies the chain aggregation in the merged stores across code
paths
3. Re-add the Store node to the worklist after calling
SimplifyDemandedBits.
4. Increase GatherAllAliasesMaxDepth from 6 to 18. That number is
arbitrary, but seems sufficient to not cause regressions in
tests.
5. Remove Chain dependencies of Memory operations on CopyfromReg
nodes as these are captured by data dependence
6. Forward loads-store values through tokenfactors containing
{CopyToReg,CopyFromReg} Values.
7. Peephole to convert buildvector of extract_vector_elt to
extract_subvector if possible (see
CodeGen/AArch64/store-merge.ll)
8. Store merging for the ARM target is restricted to 32-bit as
some in some contexts invalid 64-bit operations are being
generated. This can be removed once appropriate checks are
added.
This finishes the change Matt Arsenault started in r246307 and
jyknight's original patch.
Many tests required some changes as memory operations are now
reorderable, improving load-store forwarding. One test in
particular is worth noting:
CodeGen/PowerPC/ppc64-align-long-double.ll - Improved load-store
forwarding converts a load-store pair into a parallel store and
a memory-realized bitcast of the same value. However, because we
lose the sharing of the explicit and implicit store values we
must create another local store. A similar transformation
happens before SelectionDAG as well.
Reviewers: arsenm, hfinkel, tstellarAMD, jyknight, nhaehnle
llvm-svn: 297695
2017-03-14 08:34:14 +08:00
|
|
|
; DBGDAG-DAG: [[LOADTOKEN:t[0-9]+]]: ch = TokenFactor [[LD2]]:1, [[LD1]]:1
|
2018-03-15 05:52:13 +08:00
|
|
|
; DBGDAG-DAG: [[ST2:t[0-9]+]]: ch = store<(store 2 into %ir.tmp10, align 1)> [[LOADTOKEN]], [[LD2]], t{{[0-9]+}}, undef:i64
|
In visitSTORE, always use FindBetterChain, rather than only when UseAA is enabled.
Recommiting with compiler time improvements
Recommitting after fixup of 32-bit aliasing sign offset bug in DAGCombiner.
* Simplify Consecutive Merge Store Candidate Search
Now that address aliasing is much less conservative, push through
simplified store merging search and chain alias analysis which only
checks for parallel stores through the chain subgraph. This is cleaner
as the separation of non-interfering loads/stores from the
store-merging logic.
When merging stores search up the chain through a single load, and
finds all possible stores by looking down from through a load and a
TokenFactor to all stores visited.
This improves the quality of the output SelectionDAG and the output
Codegen (save perhaps for some ARM cases where we correctly constructs
wider loads, but then promotes them to float operations which appear
but requires more expensive constant generation).
Some minor peephole optimizations to deal with improved SubDAG shapes (listed below)
Additional Minor Changes:
1. Finishes removing unused AliasLoad code
2. Unifies the chain aggregation in the merged stores across code
paths
3. Re-add the Store node to the worklist after calling
SimplifyDemandedBits.
4. Increase GatherAllAliasesMaxDepth from 6 to 18. That number is
arbitrary, but seems sufficient to not cause regressions in
tests.
5. Remove Chain dependencies of Memory operations on CopyfromReg
nodes as these are captured by data dependence
6. Forward loads-store values through tokenfactors containing
{CopyToReg,CopyFromReg} Values.
7. Peephole to convert buildvector of extract_vector_elt to
extract_subvector if possible (see
CodeGen/AArch64/store-merge.ll)
8. Store merging for the ARM target is restricted to 32-bit as
some in some contexts invalid 64-bit operations are being
generated. This can be removed once appropriate checks are
added.
This finishes the change Matt Arsenault started in r246307 and
jyknight's original patch.
Many tests required some changes as memory operations are now
reorderable, improving load-store forwarding. One test in
particular is worth noting:
CodeGen/PowerPC/ppc64-align-long-double.ll - Improved load-store
forwarding converts a load-store pair into a parallel store and
a memory-realized bitcast of the same value. However, because we
lose the sharing of the explicit and implicit store values we
must create another local store. A similar transformation
happens before SelectionDAG as well.
Reviewers: arsenm, hfinkel, tstellarAMD, jyknight, nhaehnle
llvm-svn: 297695
2017-03-14 08:34:14 +08:00
|
|
|
|
|
|
|
; DBGDAG: X86ISD::RET_FLAG t{{[0-9]+}},
|
2015-09-24 15:22:38 +08:00
|
|
|
|
2017-08-11 21:21:35 +08:00
|
|
|
; DBGDAG-LABEL: Instruction selection begins
|
2015-09-24 15:22:38 +08:00
|
|
|
define void @merge_store_partial_overlap_load([4 x i8]* %tmp) {
|
|
|
|
%tmp8 = getelementptr inbounds [4 x i8], [4 x i8]* %tmp, i32 0, i8 0
|
|
|
|
%tmp10 = getelementptr inbounds [4 x i8], [4 x i8]* %tmp, i32 0, i8 1
|
|
|
|
%tmp12 = getelementptr inbounds [4 x i8], [4 x i8]* %tmp, i32 0, i8 2
|
|
|
|
%tmp14 = getelementptr [4 x i8], [4 x i8]* %tmp, i32 0, i8 3
|
|
|
|
|
|
|
|
%tmp9 = load i8, i8* %tmp8, align 1 ; base + 0
|
|
|
|
%tmp11 = load i8, i8* %tmp10, align 1 ; base + 1
|
|
|
|
%tmp13 = load i8, i8* %tmp12, align 1 ; base + 2
|
|
|
|
|
|
|
|
store i8 %tmp9, i8* %tmp10, align 1 ; base + 1
|
|
|
|
store i8 %tmp11, i8* %tmp12, align 1 ; base + 2
|
|
|
|
store i8 %tmp13, i8* %tmp14, align 1 ; base + 3
|
|
|
|
|
|
|
|
; Should emit
|
|
|
|
; load base + 0, base + 1
|
|
|
|
; store base + 1, base + 2
|
|
|
|
; load base + 2
|
|
|
|
; store base + 3
|
|
|
|
|
|
|
|
ret void
|
|
|
|
}
|