[PATCH] D102096: [DAGCombiner] Fix DAG combine store elimination, different address space.
Hendrik Greving via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri May 7 16:18:27 PDT 2021
hgreving created this revision.
Herald added subscribers: ecnelises, pengfei, hiraditya.
hgreving requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
Fixes a bug in the DAG combiner that eliminates the store if
%v = load %ptr
// no chain side effect
store %v, %ptr
..but missed to inspect the address space of the pointer.
Adds a test for above in x86.
https://reviews.llvm.org/D102096
Files:
llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
llvm/test/CodeGen/X86/fs_gs_dag_combine.ll
Index: llvm/test/CodeGen/X86/fs_gs_dag_combine.ll
===================================================================
--- /dev/null
+++ llvm/test/CodeGen/X86/fs_gs_dag_combine.ll
@@ -0,0 +1,43 @@
+; RUN: llc < %s -mtriple=i686-pc-linux | FileCheck %s
+
+; Checks that the store is not eliminated by the DAG combiner.
+
+; CHECK-LABEL: copy_fs_same:
+; CHECK: movl 1, %eax
+; CHECK-NEXT: movl %eax, %fs:1
+define i32 @copy_fs_same() {
+entry:
+ %0 = load i32, i32* inttoptr (i64 1 to i32*), align 4
+ store i32 %0, i32 addrspace(257)* inttoptr (i64 1 to i32 addrspace(257)*), align 4
+ ret i32 %0
+}
+
+; CHECK-LABEL: copy_fs_diff:
+; CHECK: movl 1, %eax
+; CHECK-NEXT: movl %eax, %fs:2
+define i32 @copy_fs_diff() {
+entry:
+ %0 = load i32, i32* inttoptr (i64 1 to i32*), align 4
+ store i32 %0, i32 addrspace(257)* inttoptr (i64 2 to i32 addrspace(257)*), align 4
+ ret i32 %0
+}
+
+; CHECK-LABEL: copy_gs_same:
+; CHECK: movl 1, %eax
+; CHECK-NEXT: movl %eax, %gs:1
+define i32 @copy_gs_same() {
+entry:
+ %0 = load i32, i32* inttoptr (i64 1 to i32*), align 4
+ store i32 %0, i32 addrspace(256)* inttoptr (i64 1 to i32 addrspace(256)*), align 4
+ ret i32 %0
+}
+
+; CHECK-LABEL: copy_gs_diff:
+; CHECK: movl 1, %eax
+; CHECK-NEXT: movl %eax, %gs:2
+define i32 @copy_gs_diff() {
+entry:
+ %0 = load i32, i32* inttoptr (i64 1 to i32*), align 4
+ store i32 %0, i32 addrspace(256)* inttoptr (i64 2 to i32 addrspace(256)*), align 4
+ ret i32 %0
+}
Index: llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
===================================================================
--- llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
+++ llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
@@ -17916,6 +17916,8 @@
if (LoadSDNode *Ld = dyn_cast<LoadSDNode>(Value)) {
if (Ld->getBasePtr() == Ptr && ST->getMemoryVT() == Ld->getMemoryVT() &&
ST->isUnindexed() && ST->isSimple() &&
+ Ld->getPointerInfo().getAddrSpace() ==
+ ST->getPointerInfo().getAddrSpace() &&
// There can't be any side effects between the load and store, such as
// a call or store.
Chain.reachesChainWithoutSideEffects(SDValue(Ld, 1))) {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D102096.343779.patch
Type: text/x-patch
Size: 2161 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210507/210d2c6d/attachment.bin>
More information about the llvm-commits
mailing list