<html>
<head>
<base href="https://llvm.org/bugs/" />
</head>
<body><table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Bug ID</th>
<td><a class="bz_bug_link
bz_status_NEW "
title="NEW --- - Complex and error-prone conditional expression for trivial conditional"
href="https://llvm.org/bugs/show_bug.cgi?id=27964">27964</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>Complex and error-prone conditional expression for trivial conditional
</td>
</tr>
<tr>
<th>Product</th>
<td>Polly
</td>
</tr>
<tr>
<th>Version</th>
<td>unspecified
</td>
</tr>
<tr>
<th>Hardware</th>
<td>PC
</td>
</tr>
<tr>
<th>OS</th>
<td>Linux
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>normal
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>isl
</td>
</tr>
<tr>
<th>Assignee</th>
<td>polly-dev@googlegroups.com
</td>
</tr>
<tr>
<th>Reporter</th>
<td>doerfert@cs.uni-saarland.de
</td>
</tr>
<tr>
<th>CC</th>
<td>llvm-bugs@lists.llvm.org
</td>
</tr>
<tr>
<th>Classification</th>
<td>Unclassified
</td>
</tr></table>
<p>
<div>
<pre>In the function "clause_DeleteLiteralNN" in the SPASS benchmark
(llvm-test-suite/MultiSource/Applications/SPASS/clause.c) there is a
conditional that we model correctly but for which we generate complex and
error-prone control code.
First the ScopInfo output:
-------------------------
Function: clause_DeleteLiteralNN
Region: %clause_FreeLitArray.exit---%if.end30
Max Loop Depth: 0
Invariant Accesses: {
}
Context:
[Clause.idx59.val, Indice] -> { : -9223372036854775808 <=
Clause.idx59.val <= 9223372036854775807 and -2147483648 <= Indice <=
2147483647 }
Assumed Context:
[Clause.idx59.val, Indice] -> { : }
Invalid Context:
[Clause.idx59.val, Indice] -> { : Clause.idx59.val >= 2147483648 or
Clause.idx59.val <= -2147483648 or (Clause.idx59.val < 0 and Indice >=
Clause.idx59.val) }
p0: %Clause.idx59.val
p1: %Indice
Arrays {
%struct.LITERAL_HELP** MemRef_Clause_idx60_pre-phi[*]; // Element
size 8
i32 MemRef_Clause[*]; // Element size 4
}
Arrays (Bounds as pw_affs) {
%struct.LITERAL_HELP** MemRef_Clause_idx60_pre-phi[*]; // Element
size 8
i32 MemRef_Clause[*]; // Element size 4
}
Alias Groups (1):
[[ <[Clause.idx59.val, Indice] -> { MemRef_Clause[(16)] : Indice <
Clause.idx59.val; MemRef_Clause[(18)] : Indice >= Clause.idx59.val },
[Clause.idx59.val, Indice] -> { MemRef_Clause[(17)] : Indice <
Clause.idx59.val; MemRef_Clause[(19)] : Indice >= Clause.idx59.val }>
<[Clause.idx59.val, Indice] -> { MemRef_Clause_idx60_pre-phi[(0)] },
[Clause.idx59.val, Indice] -> { MemRef_Clause_idx60_pre-phi[(1)] }> ]]
Statements {
»-Stmt_clause_FreeLitArray_exit
Domain :=
[Clause.idx59.val, Indice] -> {
Stmt_clause_FreeLitArray_exit[] };
Schedule :=
[Clause.idx59.val, Indice] -> {
Stmt_clause_FreeLitArray_exit[] -> [0] };
MustWriteAccess :=»-[Reduction Type: NONE] [Scalar: 0]
[Clause.idx59.val, Indice] -> {
Stmt_clause_FreeLitArray_exit[] -> MemRef_Clause_idx60_pre-phi[0] };
»-Stmt_if_else26
Domain :=
[Clause.idx59.val, Indice] -> { Stmt_if_else26[] : Indice >=
Clause.idx59.val };
Schedule :=
[Clause.idx59.val, Indice] -> { Stmt_if_else26[] -> [2] };
ReadAccess :=»[Reduction Type: +] [Scalar: 0]
[Clause.idx59.val, Indice] -> { Stmt_if_else26[] ->
MemRef_Clause[18] };
MustWriteAccess :=»-[Reduction Type: +] [Scalar: 0]
[Clause.idx59.val, Indice] -> { Stmt_if_else26[] ->
MemRef_Clause[18] };
»-Stmt_if_then17
Domain :=
[Clause.idx59.val, Indice] -> { Stmt_if_then17[] : Indice <
Clause.idx59.val };
Schedule :=
[Clause.idx59.val, Indice] -> { Stmt_if_then17[] -> [1] };
ReadAccess :=»[Reduction Type: +] [Scalar: 0]
[Clause.idx59.val, Indice] -> { Stmt_if_then17[] ->
MemRef_Clause[16] };
MustWriteAccess :=»-[Reduction Type: +] [Scalar: 0]
[Clause.idx59.val, Indice] -> { Stmt_if_then17[] ->
MemRef_Clause[16] };
}
and now the AST we generate:
----------------------------
[Clause.idx59.val, Indice] -> { : -9223372036854775808 <= Clause.idx59.val
<= 9223372036854775807 and -2147483648 <= Indice <= 2147483647 }
[Clause.idx59.val, Indice] -> { Stmt_if_else26[] -> [2] : Indice >=
Clause.idx59.val; Stmt_clause_FreeLitArray_exit[] -> [0];
Stmt_if_then17[] -> [1] : Indice < Clause.idx59.val }
if (1 && 0 == (Clause.idx59.val >= 2147483648 || Clause.idx59.val <=
-2147483648 || (Clause.idx59.val <= -1 && Indice >= Clause.idx59.val)) &&
(&MemRef_Clause_idx60_pre-phi[1] <= &MemRef_Clause[Clause.idx59.val >= Indice +
1 ? 16 : 18] || &MemRef_Clause[Clause.idx59.val >= Indice + 1 ? 17 :
19] <= &MemRef_Clause_idx60_pre-phi[0]))
{
Stmt_clause_FreeLitArray_exit();
if (Clause.idx59.val >= Indice + 1) {
Stmt_if_then17();
} else if (4294967296 * Indice + 4294967295 >= 4294967297 *
Clause.idx59.val)
Stmt_if_else26();
}
else
{ /* original code */ }
The complex condition for the Stmt_if_else26 can easily overflow (in fact it
does with a differen IslExprBuilder).
Does anybody have an idea why we generate this expression? (my money is on a
bug in the imath 32/64 bit handling but that's just a guess...)
Reproducible with:
clang -DCLOCK_NO_TIMING -fno-strict-aliasing -w
-I<PATH>/llvm-test-suite/MultiSource/Applications/SPASS -D_GNU_SOURCE
-D__STDC_LIMIT_MACROS -DNDEBUG -O3 -mllvm -polly -mllvm
-polly-process-unprofitable -mllvm -polly-position=before-vectorizer -mllvm
-polly-only-func=clause_DeleteLiteralNN -mllvm
-polly-only-region=clause_FreeLitArray.exit -m64 -fomit-frame-pointer -c
<PATH>/llvm-test-suite/MultiSource/Applications/SPASS/clause.c -o /dev/null
-mllvm -debug-only=polly-ast</pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are on the CC list for the bug.</li>
</ul>
</body>
</html>