[PATCH] D134732: fix vectorization of library calls
Tim Schmielau via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Sep 29 05:08:33 PDT 2022
tim.schmielau updated this revision to Diff 463850.
tim.schmielau added a comment.
Re-uploading once again. `arc diff --preview` creates a preview that looks correct, but just `arc diff` is somehow mixing in the other patch I currently have open.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D134732/new/
https://reviews.llvm.org/D134732
Files:
llvm/lib/Analysis/LoopAccessAnalysis.cpp
llvm/test/Transforms/LoopVectorize/X86/libm-vector-calls-VF2-VF8.ll
llvm/test/Transforms/LoopVectorize/X86/libm-vector-calls.ll
Index: llvm/test/Transforms/LoopVectorize/X86/libm-vector-calls.ll
===================================================================
--- llvm/test/Transforms/LoopVectorize/X86/libm-vector-calls.ll
+++ llvm/test/Transforms/LoopVectorize/X86/libm-vector-calls.ll
@@ -356,7 +356,8 @@
!132 = !{!"llvm.loop.vectorize.width", i32 4}
!133 = !{!"llvm.loop.vectorize.enable", i1 true}
-attributes #0 = { nounwind readnone }
+; functions are in fact "readnone" but clang only emits the weaker "writeonly" as other math functions may write errno.
+attributes #0 = { nounwind writeonly }
declare double @sin(double) #0
declare float @sinf(float) #0
Index: llvm/test/Transforms/LoopVectorize/X86/libm-vector-calls-VF2-VF8.ll
===================================================================
--- llvm/test/Transforms/LoopVectorize/X86/libm-vector-calls-VF2-VF8.ll
+++ llvm/test/Transforms/LoopVectorize/X86/libm-vector-calls-VF2-VF8.ll
@@ -356,7 +356,8 @@
!132 = !{!"llvm.loop.vectorize.width", i32 8}
!133 = !{!"llvm.loop.vectorize.enable", i1 true}
-attributes #0 = { nounwind readnone }
+; functions are in fact "readnone" but clang only emits the weaker "writeonly" as other math functions may write errno.
+attributes #0 = { nounwind writeonly }
declare double @sin(double) #0
declare float @sinf(float) #0
Index: llvm/lib/Analysis/LoopAccessAnalysis.cpp
===================================================================
--- llvm/lib/Analysis/LoopAccessAnalysis.cpp
+++ llvm/lib/Analysis/LoopAccessAnalysis.cpp
@@ -2189,8 +2189,8 @@
// Scan the BB and collect legal loads and stores. Also detect any
// convergent instructions.
for (Instruction &I : *BB) {
- if (auto *Call = dyn_cast<CallBase>(&I)) {
- if (Call->isConvergent())
+ if (auto *CB = dyn_cast<CallBase>(&I)) {
+ if (CB->isConvergent())
HasConvergentOp = true;
}
@@ -2205,23 +2205,24 @@
if (HasComplexMemInst)
continue;
- // If this is a load, save it. If this instruction can read from memory
- // but is not a load, then we quit. Notice that we don't handle function
- // calls that read or write.
- if (I.mayReadFromMemory()) {
+ if (auto *Call = dyn_cast<CallInst>(&I)) {
// Many math library functions read the rounding mode. We will only
// vectorize a loop if it contains known function calls that don't set
// the flag. Therefore, it is safe to ignore this read from memory.
- auto *Call = dyn_cast<CallInst>(&I);
- if (Call && getVectorIntrinsicIDForCall(Call, TLI))
+ if (getVectorIntrinsicIDForCall(Call, TLI))
continue;
// If the function has an explicit vectorized counterpart, we can safely
// assume that it can be vectorized.
- if (Call && !Call->isNoBuiltin() && Call->getCalledFunction() &&
+ if (!Call->isNoBuiltin() && Call->getCalledFunction() &&
!VFDatabase::getMappings(*Call).empty())
continue;
+ }
+ // If this is a load, save it. If this instruction can read from memory
+ // but is not a load, then we quit. Notice that we don't handle function
+ // calls that read or write.
+ if (I.mayReadFromMemory()) {
auto *Ld = dyn_cast<LoadInst>(&I);
if (!Ld) {
recordAnalysis("CantVectorizeInstruction", Ld)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D134732.463850.patch
Type: text/x-patch
Size: 3377 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220929/493bf323/attachment.bin>
More information about the llvm-commits
mailing list