[llvm] [LICM] Promote conditional, loop-invariant memory accesses to scalars with intrinsic (PR #93999)
Matt Arsenault via llvm-commits
llvm-commits at lists.llvm.org
Fri May 31 14:26:51 PDT 2024
================
@@ -0,0 +1,115 @@
+//===- 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(Instruction &Instr) {
+ CallInst *CI = dyn_cast<CallInst>(&Instr);
+ if (!CI)
+ return false;
+
+ Function *Fn = CI->getCalledFunction();
----------------
arsenm wrote:
dyn_cast<IntrinsicInst>, and don't need to go through getCalledFunction
https://github.com/llvm/llvm-project/pull/93999
More information about the llvm-commits
mailing list