<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 --- - missed x.with.overflow optimizations"
href="https://llvm.org/bugs/show_bug.cgi?id=27094">27094</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>missed x.with.overflow optimizations
</td>
</tr>
<tr>
<th>Product</th>
<td>new-bugs
</td>
</tr>
<tr>
<th>Version</th>
<td>trunk
</td>
</tr>
<tr>
<th>Hardware</th>
<td>PC
</td>
</tr>
<tr>
<th>OS</th>
<td>All
</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>new bugs
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>regehr@cs.utah.edu
</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>Here are a couple of examples where we should teach SCEV to see that the
overflows aren't going to happen.
regehr@hawking:~$ cat foo.c
void foo1(char *a) {
for (int i = 0; i < 16; i++)
a[i] = 0;
}
void foo2(char *a) {
for (int i = 15; i >= 0; i--)
a[i] = 0;
}
regehr@hawking:~$ clang -O2 -fsanitize=signed-integer-overflow
-fsanitize-trap=signed-integer-overflow foo.c -S -o - -emit-llvm
; ModuleID = 'foo.c'
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"
; Function Attrs: nounwind uwtable
define void @foo1(i8* nocapture %a) #0 {
entry:
br label %for.body
for.cond.cleanup: ; preds = %cont
ret void
for.body: ; preds = %entry, %cont
%i.04 = phi i32 [ 0, %entry ], [ %2, %cont ]
%idxprom = sext i32 %i.04 to i64
%arrayidx = getelementptr inbounds i8, i8* %a, i64 %idxprom
store i8 0, i8* %arrayidx, align 1, !tbaa !1
%0 = tail call { i32, i1 } @llvm.sadd.with.overflow.i32(i32 %i.04, i32 1)
%1 = extractvalue { i32, i1 } %0, 1
br i1 %1, label %trap, label %cont, !nosanitize !4
trap: ; preds = %for.body
tail call void @llvm.trap() #2, !nosanitize !4
unreachable, !nosanitize !4
cont: ; preds = %for.body
%2 = extractvalue { i32, i1 } %0, 0
%cmp = icmp slt i32 %2, 16
br i1 %cmp, label %for.body, label %for.cond.cleanup
}
; Function Attrs: nounwind readnone
declare { i32, i1 } @llvm.sadd.with.overflow.i32(i32, i32) #1
; Function Attrs: noreturn nounwind
declare void @llvm.trap() #2
; Function Attrs: nounwind uwtable
define void @foo2(i8* nocapture %a) #0 {
entry:
br label %for.body
for.cond.cleanup: ; preds = %cont
ret void
for.body: ; preds = %entry, %cont
%i.04 = phi i32 [ 15, %entry ], [ %2, %cont ]
%idxprom = sext i32 %i.04 to i64
%arrayidx = getelementptr inbounds i8, i8* %a, i64 %idxprom
store i8 0, i8* %arrayidx, align 1, !tbaa !1
%0 = tail call { i32, i1 } @llvm.ssub.with.overflow.i32(i32 %i.04, i32 1)
%1 = extractvalue { i32, i1 } %0, 1
br i1 %1, label %trap, label %cont, !nosanitize !4
trap: ; preds = %for.body
tail call void @llvm.trap() #2, !nosanitize !4
unreachable, !nosanitize !4
cont: ; preds = %for.body
%2 = extractvalue { i32, i1 } %0, 0
%cmp = icmp sgt i32 %2, -1
br i1 %cmp, label %for.body, label %for.cond.cleanup
}
; Function Attrs: nounwind readnone
declare { i32, i1 } @llvm.ssub.with.overflow.i32(i32, i32) #1
attributes #0 = { nounwind uwtable "disable-tail-calls"="false"
"less-precise-fpmad"="false" "no-frame-pointer-elim"="false"
"no-infs-fp-math"="false" "no-nans-fp-math"="false"
"stack-protector-buffer-size"="8" "target-cpu"="x86-64"
"target-features"="+fxsr,+mmx,+sse,+sse2,+x87" "unsafe-fp-math"="false"
"use-soft-float"="false" }
attributes #1 = { nounwind readnone }
attributes #2 = { noreturn nounwind }
!llvm.ident = !{!0}
!0 = !{!"clang version 3.9.0 (trunk 264413)"}
!1 = !{!2, !2, i64 0}
!2 = !{!"omnipotent char", !3, i64 0}
!3 = !{!"Simple C/C++ TBAA"}
!4 = !{}</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>