<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 - loop-reduce introduce invnalid ptrtoint/inttoptr"
href="https://bugs.llvm.org/show_bug.cgi?id=46757">46757</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>loop-reduce introduce invnalid ptrtoint/inttoptr
</td>
</tr>
<tr>
<th>Product</th>
<td>libraries
</td>
</tr>
<tr>
<th>Version</th>
<td>trunk
</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>Loop Optimizer
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>yyc1992@gmail.com
</td>
</tr>
<tr>
<th>CC</th>
<td>llvm-bugs@lists.llvm.org
</td>
</tr></table>
<p>
<div>
<pre>Optimizing the code below with `opt -loop-reduce` causes incorrect `inttoptr`
to be emitted for the non-integral pointer.
```
target datalayout =
"e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64-ni:10:11:12:13"
target triple = "armv7l-unknown-linux-gnueabihf"
define dso_local void @julia_roundup_19730() {
top:
br label %L37
L37: ; preds = %L49, %top
%value_phi7 = phi i32 [ %3, %L49 ], [ 0, %top ]
br i1 undef, label %L49, label %L47
L47: ; preds = %L37
unreachable
L49: ; preds = %L37
%0 = add i32 %value_phi7, -2
%1 = getelementptr inbounds i8, i8 addrspace(13)* null, i32 %0
%2 = load i8, i8 addrspace(13)* %1, align 1
%3 = add i32 %value_phi7, -1
br label %L37
}
```
The transformation done is,
```
*** IR Dump Before Loop Strength Reduction ***
; Preheader:
top:
br label %L37
; Loop:
L37: ; preds = %L49, %top
%value_phi7 = phi i32 [ %3, %L49 ], [ 0, %top ]
br i1 false, label %L49, label %L47
L49: ; preds = %L37
%0 = add i32 %value_phi7, -2
%1 = getelementptr inbounds i8, i8 addrspace(13)* null, i32 %0
%2 = load i8, i8 addrspace(13)* %1, align 1
%3 = add i32 %value_phi7, -1
br label %L37
; Exit blocks
L47: ; preds = %L37
unreachable
*** IR Dump After Loop Strength Reduction ***
; Preheader:
top:
br label %L37
; Loop:
L37: ; preds = %L49, %top
%lsr.iv = phi i32 [ %lsr.iv.next, %L49 ], [ -2, %top ]
%lsr.iv1 = inttoptr i32 %lsr.iv to i8 addrspace(13)*
br i1 false, label %L49, label %L47
L49: ; preds = %L37
%0 = load i8, i8 addrspace(13)* %lsr.iv1, align 1
%lsr.iv.next = add nsw i32 %lsr.iv, -1
br label %L37
; Exit blocks
L47: ; preds = %L37
unreachable
```
Reproducible as of a week ago on master.</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>