Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ComplexDeinterleaving pass can be very slow on certain input #64379

Closed
igogo-x86 opened this issue Aug 3, 2023 · 5 comments · Fixed by llvm/llvm-project-release-prs#528
Closed

Comments

@igogo-x86
Copy link
Contributor

When identifying complex deinterleaving operations, we do not cache unsuccessful results, which leads to repeatedly running the same algorithm for the same input. For example, it takes to 4 seconds to compile this code on my machine:

#include <complex>

; // complex SP in C++
using namespace std;
using namespace std::complex_literals;

void func(complex<double> *__restrict__ a, complex<double> *__restrict__ b, complex<double> *__restrict__ c, complex<double> *__restrict__ u) {
#pragma clang loop vectorize(enable) unroll(disable)
      for (int i = 0; i < 100; ++i) {
           u[i] = u[i].real() + u[i].imag();
           u[i] = u[i] * (a[i] * b[i] + c[i]);
           u[i] = u[i] * (a[i] * b[i] + c[i]);
           u[i] = u[i] * (a[i] * b[i] + c[i]);
           u[i] = u[i] * (a[i] * b[i] + c[i]);
           u[i] = u[i] * (a[i] * b[i] + c[i]);
           u[i] = u[i] * (a[i] * b[i] + c[i]);
           u[i] = u[i] * (a[i] * b[i] + c[i]);
           u[i] = u[i] * (a[i] * b[i] + c[i]);
           u[i] = u[i] * (a[i] * b[i] + c[i]);
      }
}

And after adding one extra u[i] = u[i] * (a[i] * b[i] + c[i]); line it takes 23 seconds.

@igogo-x86 igogo-x86 added this to the LLVM 17.0.X Release milestone Aug 3, 2023
@igogo-x86 igogo-x86 self-assigned this Aug 3, 2023
@igogo-x86
Copy link
Contributor Author

Review with a fix - https://reviews.llvm.org/D156916

@igogo-x86
Copy link
Contributor Author

/cherry-pick 46b2ad0

@llvmbot
Copy link
Collaborator

llvmbot commented Aug 4, 2023

/branch llvm/llvm-project-release-prs/issue64379

llvmbot pushed a commit to llvm/llvm-project-release-prs that referenced this issue Aug 4, 2023
Cache all results of running `identifyNode`, even those that do not identify
potential complex operations. This patch prevents ComplexDeinterleaving pass
from repeatedly trying to identify Nodes for the same pair of instructions.

Fixes llvm/llvm-project#64379

Differential Revision: https://reviews.llvm.org/D156916

(cherry picked from commit 46b2ad0)
@llvmbot
Copy link
Collaborator

llvmbot commented Aug 4, 2023

/pull-request llvm/llvm-project-release-prs#528

@tru
Copy link
Collaborator

tru commented Aug 7, 2023

Re-open until it's merged to the release branch. Need confirmation by @NickGuy-Arm

@tru tru reopened this Aug 7, 2023
tru pushed a commit to llvm/llvm-project-release-prs that referenced this issue Aug 9, 2023
Cache all results of running `identifyNode`, even those that do not identify
potential complex operations. This patch prevents ComplexDeinterleaving pass
from repeatedly trying to identify Nodes for the same pair of instructions.

Fixes llvm/llvm-project#64379

Differential Revision: https://reviews.llvm.org/D156916

(cherry picked from commit 46b2ad0)
razmser pushed a commit to razmser/llvm-project that referenced this issue Sep 8, 2023
Cache all results of running `identifyNode`, even those that do not identify
potential complex operations. This patch prevents ComplexDeinterleaving pass
from repeatedly trying to identify Nodes for the same pair of instructions.

Fixes llvm#64379

Differential Revision: https://reviews.llvm.org/D156916
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment