[llvm-bugs] [Bug 27964] New: Complex and error-prone conditional expression for trivial conditional
via llvm-bugs
llvm-bugs at lists.llvm.org
Wed Jun 1 08:49:16 PDT 2016
https://llvm.org/bugs/show_bug.cgi?id=27964
Bug ID: 27964
Summary: Complex and error-prone conditional expression for
trivial conditional
Product: Polly
Version: unspecified
Hardware: PC
OS: Linux
Status: NEW
Severity: normal
Priority: P
Component: isl
Assignee: polly-dev at googlegroups.com
Reporter: doerfert at cs.uni-saarland.de
CC: llvm-bugs at lists.llvm.org
Classification: Unclassified
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
--
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20160601/28dc856c/attachment.html>
More information about the llvm-bugs
mailing list