[llvm] r334020 - DAG: Stop dropping invariant/dereferencable

Matt Arsenault via llvm-commits llvm-commits at lists.llvm.org
Tue Jun 5 07:52:24 PDT 2018


Author: arsenm
Date: Tue Jun  5 07:52:24 2018
New Revision: 334020

URL: http://llvm.org/viewvc/llvm-project?rev=334020&view=rev
Log:
DAG: Stop dropping invariant/dereferencable

When legalizing illegal FP load results, this was
for some reason dropping the invariant and dereferencable
memory flags. There doesn't seem to be any reason for this,
and the equivalent isn't done for integer loads.

Fixes an issue in a future AMDGPU commit where some identical
loads fail to merge because one of the loads ends up
dropping the flags.

Added:
    llvm/trunk/test/CodeGen/AMDGPU/legalize-fp-load-invariant.ll
Modified:
    llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeFloatTypes.cpp

Modified: llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeFloatTypes.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeFloatTypes.cpp?rev=334020&r1=334019&r2=334020&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeFloatTypes.cpp (original)
+++ llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeFloatTypes.cpp Tue Jun  5 07:52:24 2018
@@ -2102,13 +2102,12 @@ SDValue DAGTypeLegalizer::PromoteFloatRe
 
   // Load the value as an integer value with the same number of bits.
   EVT IVT = EVT::getIntegerVT(*DAG.getContext(), VT.getSizeInBits());
-  auto MMOFlags =
-      L->getMemOperand()->getFlags() &
-      ~(MachineMemOperand::MOInvariant | MachineMemOperand::MODereferenceable);
   SDValue newL = DAG.getLoad(L->getAddressingMode(), L->getExtensionType(), IVT,
                              SDLoc(N), L->getChain(), L->getBasePtr(),
                              L->getOffset(), L->getPointerInfo(), IVT,
-                             L->getAlignment(), MMOFlags, L->getAAInfo());
+                             L->getAlignment(),
+                             L->getMemOperand()->getFlags(),
+                             L->getAAInfo());
   // Legalize the chain result by replacing uses of the old value chain with the
   // new one
   ReplaceValueWith(SDValue(N, 1), newL.getValue(1));

Added: llvm/trunk/test/CodeGen/AMDGPU/legalize-fp-load-invariant.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/AMDGPU/legalize-fp-load-invariant.ll?rev=334020&view=auto
==============================================================================
--- llvm/trunk/test/CodeGen/AMDGPU/legalize-fp-load-invariant.ll (added)
+++ llvm/trunk/test/CodeGen/AMDGPU/legalize-fp-load-invariant.ll Tue Jun  5 07:52:24 2018
@@ -0,0 +1,13 @@
+; RUN: llc -march=amdgcn -mcpu=tahiti -verify-machineinstrs -stop-after=isel -o - %s | FileCheck -check-prefix=GCN %s
+
+; Type legalization for illegal FP type results was dropping invariant
+; and dereferenceable flags.
+
+; GCN: BUFFER_LOAD_USHORT_OFFSET killed %{{[0-9]+}}, 0, 0, 0, 0, 0, implicit $exec :: (dereferenceable invariant load 2 from %ir.ptr, addrspace 4)
+define half @legalize_f16_load(half addrspace(4)* dereferenceable(4) %ptr) {
+  %load = load half, half addrspace(4)* %ptr, !invariant.load !0
+  %add = fadd half %load, 1.0
+  ret half %add
+}
+
+!0 = !{}




More information about the llvm-commits mailing list