[llvm] cd12e79 - [x86] Propagate memory operands during ISel DAG postprocessing

Jean-Michel Gorius via llvm-commits llvm-commits at lists.llvm.org
Mon May 18 12:35:38 PDT 2020


Author: Jean-Michel Gorius
Date: 2020-05-18T21:35:31+02:00
New Revision: cd12e79e6ddd235739716fff5c6a748915f664b9

URL: https://github.com/llvm/llvm-project/commit/cd12e79e6ddd235739716fff5c6a748915f664b9
DIFF: https://github.com/llvm/llvm-project/commit/cd12e79e6ddd235739716fff5c6a748915f664b9.diff

LOG: [x86] Propagate memory operands during ISel DAG postprocessing

Summary:
Propagate memory operands when folding test instructions.

This was split from D80062.

Reviewers: craig.topper, rnk, lebedev.ri

Reviewed By: craig.topper

Subscribers: hiraditya, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D80140

Added: 
    llvm/test/CodeGen/X86/isel-postprocessing-test-fold-memop.ll

Modified: 
    llvm/lib/Target/X86/X86ISelDAGToDAG.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Target/X86/X86ISelDAGToDAG.cpp b/llvm/lib/Target/X86/X86ISelDAGToDAG.cpp
index ab816ecc559d..ffe9d432ccdf 100644
--- a/llvm/lib/Target/X86/X86ISelDAGToDAG.cpp
+++ b/llvm/lib/Target/X86/X86ISelDAGToDAG.cpp
@@ -1388,6 +1388,8 @@ void X86DAGToDAGISel::PostprocessISelDAG() {
                           And.getOperand(6)  /* Chain */ };
         MachineSDNode *Test = CurDAG->getMachineNode(NewOpc, SDLoc(N),
                                                      MVT::i32, MVT::Other, Ops);
+        CurDAG->setNodeMemRefs(
+            Test, cast<MachineSDNode>(And.getNode())->memoperands());
         ReplaceUses(N, Test);
         MadeChange = true;
         continue;

diff  --git a/llvm/test/CodeGen/X86/isel-postprocessing-test-fold-memop.ll b/llvm/test/CodeGen/X86/isel-postprocessing-test-fold-memop.ll
new file mode 100644
index 000000000000..99a80fae441b
--- /dev/null
+++ b/llvm/test/CodeGen/X86/isel-postprocessing-test-fold-memop.ll
@@ -0,0 +1,14 @@
+; RUN: llc -O2 -mtriple=x86_64-- -stop-after=finalize-isel < %s | FileCheck %s
+
+define i1 @fold_test(i64* %x, i64 %l) {
+entry:
+  %0 = load i64, i64* %x, align 8
+  %and = and i64 %0, %l
+  %tobool = icmp ne i64 %and, 0
+  ret i1 %tobool
+
+  ; Folding the load+and+icmp instructions into a TEST64mr instruction
+  ; should preserve memory operands.
+  ; CHECK: TEST64mr {{.*}} :: (load 8 from {{%.*}})
+}
+


        


More information about the llvm-commits mailing list