<html>
<head>
<base href="https://bugs.llvm.org/">
</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 - tailcallelim change the semantic of my program"
href="https://bugs.llvm.org/show_bug.cgi?id=44304">44304</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>tailcallelim change the semantic of my program
</td>
</tr>
<tr>
<th>Product</th>
<td>new-bugs
</td>
</tr>
<tr>
<th>Version</th>
<td>8.0
</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>enhancement
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>new bugs
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>hzx19990925@mail.ustc.edu.cn
</td>
</tr>
<tr>
<th>CC</th>
<td>htmldeveloper@gmail.com, llvm-bugs@lists.llvm.org
</td>
</tr></table>
<p>
<div>
<pre>Created <span class=""><a href="attachment.cgi?id=22937" name="attach_22937" title="code before optimization">attachment 22937</a> <a href="attachment.cgi?id=22937&action=edit" title="code before optimization">[details]</a></span>
code before optimization
I got the LLVM IR Code from
/llvm/test/Transforms/TailCallEli/accum_recursion.ll
I add a main function to test it.
The code is below.Also,I will add an attachment of my LLVM IR code and the code
after optimization.
I use tailcallelim pass to optimize it,use lli to test the output:
lli accum_recursion.ll
echo $?
2
opt -tailcallelim accum_recursion.ll -o accum_recursion_opt.ll
lli lli accum_recursion_opt.ll
echo $?
6
The output is different.So I think this optimization change the semantic of the
program.
This is the code before optimization:
define i64 @test3_fib(i64 %n) nounwind readnone {
; CHECK: @test3_fib
entry:
; CHECK: tailrecurse:
; CHECK: %accumulator.tr = phi i64 [ %n, %entry ], [ %3, %bb1 ]
; CHECK: %n.tr = phi i64 [ %n, %entry ], [ %2, %bb1 ]
switch i64 %n, label %bb1 [
; CHECK: switch i64 %n.tr, label %bb1 [
i64 0, label %bb2
i64 1, label %bb2
]
bb1:
; CHECK: bb1:
%0 = add i64 %n, -1
; CHECK: %0 = add i64 %n.tr, -1
%1 = tail call i64 @test3_fib(i64 %0) nounwind
; CHECK: %1 = tail call i64 @test3_fib(i64 %0)
%2 = add i64 %n, -2
; CHECK: %2 = add i64 %n.tr, -2
%3 = tail call i64 @test3_fib(i64 %2) nounwind
; CHECK-NOT: tail call i64 @test3_fib
%4 = add nsw i64 %3, %1
; CHECK: add nsw i64 %accumulator.tr, %1
ret i64 %4
; CHECK: br label %tailrecurse
bb2:
; CHECK: bb2:
ret i64 %n
; CHECK: ret i64 %accumulator.tr
}
define i64 @main()
{
%1 = call i64 @test3_fib(i64 3)
ret i64 %1
}</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>