[llvm] 652b375 - [x86] add test/code comment for chain value use (PR46195); NFC

Sanjay Patel via llvm-commits llvm-commits at lists.llvm.org
Thu Jun 4 06:17:30 PDT 2020


Author: Sanjay Patel
Date: 2020-06-04T09:15:17-04:00
New Revision: 652b3757c848770885c1dc8f55292b427de1efa2

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

LOG: [x86] add test/code comment for chain value use (PR46195); NFC

Added: 
    llvm/test/CodeGen/X86/load-chain.ll

Modified: 
    llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
index d960a7427176..f603a7c12feb 100644
--- a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
@@ -1237,8 +1237,11 @@ SDValue DAGCombiner::PromoteIntBinOp(SDValue Op) {
     SDValue RV =
         DAG.getNode(ISD::TRUNCATE, DL, VT, DAG.getNode(Opc, DL, PVT, NN0, NN1));
 
-    // We are always replacing N0/N1's use in N and only need
-    // additional replacements if there are additional uses.
+    // We are always replacing N0/N1's use in N and only need additional
+    // replacements if there are additional uses.
+    // Note: We are checking uses of the *nodes* (SDNode) rather than values
+    //       (SDValue) here because the node may reference multiple values
+    //       (for example, the chain value of a load node).
     Replace0 &= !N0->hasOneUse();
     Replace1 &= (N0 != N1) && !N1->hasOneUse();
 

diff  --git a/llvm/test/CodeGen/X86/load-chain.ll b/llvm/test/CodeGen/X86/load-chain.ll
new file mode 100644
index 000000000000..cb75cfb60397
--- /dev/null
+++ b/llvm/test/CodeGen/X86/load-chain.ll
@@ -0,0 +1,31 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc < %s -mtriple=x86_64-- | FileCheck %s
+
+; PR46195 - https://bugs.llvm.org/show_bug.cgi?id=46195
+; It is not safe to sink the load after the call.
+
+define void @translate(i16* %ptr) nounwind {
+; CHECK-LABEL: translate:
+; CHECK:       # %bb.0:
+; CHECK-NEXT:    pushq %rbp
+; CHECK-NEXT:    pushq %rbx
+; CHECK-NEXT:    pushq %rax
+; CHECK-NEXT:    movq %rdi, %rbx
+; CHECK-NEXT:    movl $-32707, %ebp # imm = 0x803D
+; CHECK-NEXT:    andl (%rdi), %ebp
+; CHECK-NEXT:    callq maybe_mutate
+; CHECK-NEXT:    orl $514, %ebp # imm = 0x202
+; CHECK-NEXT:    movw %bp, (%rbx)
+; CHECK-NEXT:    addq $8, %rsp
+; CHECK-NEXT:    popq %rbx
+; CHECK-NEXT:    popq %rbp
+; CHECK-NEXT:    retq
+  %i0 = load i16, i16* %ptr, align 4
+  call void @maybe_mutate(i16* %ptr)
+  %i1 = and i16 %i0, -32707
+  %i2 = or i16 %i1, 514
+  store i16 %i2, i16* %ptr, align 4
+  ret void
+}
+
+declare void @maybe_mutate(i16*)


        


More information about the llvm-commits mailing list