[llvm] [LICM] Promote conditional, loop-invariant memory accesses to scalars with intrinsic (PR #93999)

Thomas Symalla via llvm-commits llvm-commits at lists.llvm.org
Mon Jun 10 07:03:39 PDT 2024


================
@@ -0,0 +1,108 @@
+//===- LowerConditionalStoreIntrinsic.cpp -----------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "llvm/Transforms/Scalar/LowerConditionalStoreIntrinsic.h"
+#include "llvm/IR/BasicBlock.h"
+#include "llvm/IR/Function.h"
+#include "llvm/IR/IRBuilder.h"
+#include "llvm/IR/Instructions.h"
+#include "llvm/IR/Intrinsics.h"
+#include "llvm/InitializePasses.h"
+#include "llvm/Pass.h"
+#include "llvm/Support/Debug.h"
+#include "llvm/Transforms/Scalar.h"
+#include "llvm/Transforms/Utils/BasicBlockUtils.h"
+
+using namespace llvm;
+
+#define DEBUG_TYPE "lower-cond-store-intrinsic"
+
+// Conditional store intrinsic removal:
+// block:
+//  llvm.conditional.store.*(Val, Ptr, Condition)
+//                         |
+//                         V
+// block:
+//  br %i1 Condition, label cond.store, label block.remaining
+// cond.tore:
+//  store * Val, Ptr
+//  br label block.remaining
+// block.remaining:
+
+static bool isCondStoreIntr(const Instruction &Instr) {
+  const CallInst *CI = dyn_cast<const CallInst>(&Instr);
+  return CI && CI->getIntrinsicID() == Intrinsic::conditional_store;
+}
+
+static void lowerCondStoreIntr(Instruction &Instr) {
+  LLVM_DEBUG(dbgs() << "Found basic with conditional store: "
----------------
tsymalla wrote:

Did you mean `found conditional store intrinsic`?

https://github.com/llvm/llvm-project/pull/93999


More information about the llvm-commits mailing list