https://llvm.org/bugs/show_bug.cgi?id=27094
Bug ID: 27094 Summary: missed x.with.overflow optimizations Product: new-bugs Version: trunk Hardware: PC OS: All Status: NEW Severity: normal Priority: P Component: new bugs Assignee: unassignedb...@nondot.org Reporter: reg...@cs.utah.edu CC: llvm-bugs@lists.llvm.org Classification: Unclassified 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 = !{} -- You are receiving this mail because: You are on the CC list for the bug.
_______________________________________________ llvm-bugs mailing list llvm-bugs@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs