[PATCH] D102243: [DAGCombiner] Add test exposing bug in DAG combine.

Hendrik Greving via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue May 11 07:47:33 PDT 2021


hgreving created this revision.
hgreving added reviewers: spatel, RKSimon.
Herald added a subscriber: pengfei.
hgreving requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Adds a test in X86, exposing a bug in DAG combine eliminating stores that
are the same value but no the same address space.


https://reviews.llvm.org/D102243

Files:
  llvm/test/CodeGen/X86/dagcombine-dead-store.ll


Index: llvm/test/CodeGen/X86/dagcombine-dead-store.ll
===================================================================
--- /dev/null
+++ llvm/test/CodeGen/X86/dagcombine-dead-store.ll
@@ -0,0 +1,85 @@
+; RUN: llc < %s -mtriple=i686-pc-linux | FileCheck %s
+
+; Checks that the stores aren't eliminated by the DAG combiner, because the address
+; spaces are different. In X86, we're checking this for two non-zero address spaces,
+; one for :fs and one for :gs. The test's 'same' and 'diff' notation depicts the
+; pointer value exposing bugs hitting corner cases where the case where the pointer
+; value is either the same, or different.
+
+; FIXME: DAG combine incorrectly eliminates store if pointer is of same value.
+
+; CHECK-LABEL: copy_fs_same:
+; CHECK: movl 1, %eax
+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
+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
+}
+
+; CHECK-LABEL: output_fs_same:
+; CHECK: movl %eax, 1
+define void @output_fs_same(i32 %v) {
+entry:
+  store i32 %v, i32* inttoptr (i64 1 to i32*), align 4
+  store i32 %v, i32 addrspace(257)* inttoptr (i64 1 to i32 addrspace(257)*), align 4
+  ret void
+}
+
+; CHECK-LABEL: output_fs_diff:
+; CHECK: movl %eax, 1
+; CHECK-NEXT: movl %eax, %fs:2
+define void @output_fs_diff(i32 %v) {
+entry:
+  store i32 %v, i32* inttoptr (i64 1 to i32*), align 4
+  store i32 %v, i32 addrspace(257)* inttoptr (i64 2 to i32 addrspace(257)*), align 4
+  ret void
+}
+
+; CHECK-LABEL: output_gs_same:
+; CHECK: movl %eax, 1
+define void @output_gs_same(i32 %v) {
+entry:
+  store i32 %v, i32* inttoptr (i64 1 to i32*), align 4
+  store i32 %v, i32 addrspace(256)* inttoptr (i64 1 to i32 addrspace(256)*), align 4
+  ret void
+}
+
+; CHECK-LABEL: output_gs_diff:
+; CHECK: movl %eax, 1
+; CHECK-NEXT: movl %eax, %gs:2
+define void @output_gs_diff(i32 %v) {
+entry:
+  store i32 %v, i32* inttoptr (i64 1 to i32*), align 4
+  store i32 %v, i32 addrspace(256)* inttoptr (i64 2 to i32 addrspace(256)*), align 4
+  ret void
+}


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D102243.344402.patch
Type: text/x-patch
Size: 2912 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210511/3c5f98bc/attachment.bin>


More information about the llvm-commits mailing list