Tingyuan LIANG via llvm-dev
2019-Jul-07 04:12 UTC
[llvm-dev] Report of Potential Risks when Using Loop Extractor Pass
Dear all,
Hi! Recently, I use loop extractor pass in the latest version, which
extracts loops into functions, to optimize part of the code.
However, I notice some problems which might be caused by the assumption of
loop extractor and lead to some functionalities may miss in the transformed IR
code.
I walk around the problem by inserting redundant basic blocks for loop
header but I think it could cause problem for someone else.
I guess the problem is caused by the assumption shown in
llvm/lib/Transforms/Utils/CodeExtractor.cpp
================================================Function
*CodeExtractor::extractCodeRegion() {
// Assumption: this is a single-entry code region, and the header is the first
// block in the region.
================================================
You can try to reproduce the problem with the following simple source code.
You can notice that the if-else branch is gone and the IR code is wrong.
================================================
void f( int A[56][100], int *C)
{
int N = 100;
int M = 56;
for ( int j = 1; j < N; j++ )
for ( int i = 1; i < M+1; i++ )
{
A[i][j] = A[i-1][j-1] + A[i][j-1] + A[i-1][j] + 1;
}
if (*C>10)
{
*C = 10;
for ( int j = 1; j < N; j++ )
for ( int i = 1; i < M+1; i++ )
{
A[i][j] = A[i-1][j-1] + A[i][j-1] + A[i-1][j] + 1;
}
}
return;
}
================================================
Best regards,
------------------------------------------
Tingyuan LIANG
MPhil Student
Department of Electronic and Computer Engineering
The Hong Kong University of Science and Technology
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://lists.llvm.org/pipermail/llvm-dev/attachments/20190707/6bae1134/attachment.html>
Tingyuan LIANG via llvm-dev
2019-Jul-07 04:26 UTC
[llvm-dev] Report of Potential Risks when Using Loop Extractor Pass
Dear all,
Hi! I would like to withdraw the report since I found that the problem is
caused by my own optimization code.
THANKS for your time! ^_^
Best regards,
------------------------------------------
Tingyuan LIANG
MPhil Student
Department of Electronic and Computer Engineering
The Hong Kong University of Science and Technology
________________________________
From: Tingyuan LIANG
Sent: Sunday, July 7, 2019 12:12 PM
To: llvm-dev at lists.llvm.org
Subject: Report of Potential Risks when Using Loop Extractor Pass
Dear all,
Hi! Recently, I use loop extractor pass in the latest version, which
extracts loops into functions, to optimize part of the code.
However, I notice some problems which might be caused by the assumption of
loop extractor and lead to some functionalities may miss in the transformed IR
code.
I walk around the problem by inserting redundant basic blocks for loop
header but I think it could cause problem for someone else.
I guess the problem is caused by the assumption shown in
llvm/lib/Transforms/Utils/CodeExtractor.cpp
================================================Function
*CodeExtractor::extractCodeRegion() {
// Assumption: this is a single-entry code region, and the header is the first
// block in the region.
================================================
You can try to reproduce the problem with the following simple source code.
You can notice that the if-else branch is gone and the IR code is wrong.
================================================
void f( int A[56][100], int *C)
{
int N = 100;
int M = 56;
for ( int j = 1; j < N; j++ )
for ( int i = 1; i < M+1; i++ )
{
A[i][j] = A[i-1][j-1] + A[i][j-1] + A[i-1][j] + 1;
}
if (*C>10)
{
*C = 10;
for ( int j = 1; j < N; j++ )
for ( int i = 1; i < M+1; i++ )
{
A[i][j] = A[i-1][j-1] + A[i][j-1] + A[i-1][j] + 1;
}
}
return;
}
================================================
Best regards,
------------------------------------------
Tingyuan LIANG
MPhil Student
Department of Electronic and Computer Engineering
The Hong Kong University of Science and Technology
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://lists.llvm.org/pipermail/llvm-dev/attachments/20190707/1c6187a9/attachment.html>