[llvm] [clang] [LV][LAA] Vectorize math lib calls with mem write-only attribute (PR #78432)

Nikita Popov via cfe-commits cfe-commits at lists.llvm.org
Thu Jan 18 06:59:31 PST 2024


================
@@ -2274,6 +2274,26 @@ bool LoopAccessInfo::canAnalyzeLoop() {
   return true;
 }
 
+/// Returns whether \p I is a known math library call that has attribute
+/// 'memory(argmem: write)' set.
+static bool isMathLibCallMemWriteOnly(const TargetLibraryInfo *TLI,
+                                      const Instruction &I) {
+  auto *Call = dyn_cast<CallInst>(&I);
+  if (!Call)
+    return false;
+
+  Function *F = Call->getCalledFunction();
+  if (!F->hasFnAttribute(Attribute::AttrKind::Memory))
+    return false;
+
+  auto ME = F->getFnAttribute(Attribute::AttrKind::Memory).getMemoryEffects();
----------------
nikic wrote:

You can use `Call->getMemoryEffects()` instead and skip all the code above.

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


More information about the cfe-commits mailing list