[LLVMbugs] [Bug 20194] New: with.overflow intrinsics not removed for arithmetic that trivially cannot overflow

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Wed Jul 2 16:13:27 PDT 2014


http://llvm.org/bugs/show_bug.cgi?id=20194

            Bug ID: 20194
           Summary: with.overflow intrinsics not removed for arithmetic
                    that trivially cannot overflow
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: Scalar Optimizations
          Assignee: unassignedbugs at nondot.org
          Reporter: richard-llvm at metafoo.co.uk
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified

The following IR contains a 'llvm.sadd.with.overflow.i32' intrinsic that
trivially cannot ever overflow. We're unable to optimize out the overflow
check.


target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

@min = common global i8 0, align 1

; Function Attrs: nounwind uwtable
define i32 @main() #0 {
entry:
  %0 = load i8* @min, align 1, !tbaa !1
  %conv = sext i8 %0 to i32
  %1 = tail call { i32, i1 } @llvm.sadd.with.overflow.i32(i32 %conv, i32 %conv)
  %2 = extractvalue { i32, i1 } %1, 1
  br i1 %2, label %trap, label %cont

trap:                                             ; preds = %entry
  tail call void @llvm.trap() #2
  unreachable

cont:                                             ; preds = %entry
  %3 = extractvalue { i32, i1 } %1, 0
  ret i32 %3
}

; Function Attrs: nounwind readnone
declare { i32, i1 } @llvm.sadd.with.overflow.i32(i32, i32) #1

; Function Attrs: noreturn nounwind
declare void @llvm.trap() #2

attributes #0 = { nounwind uwtable "less-precise-fpmad"="false"
"no-frame-pointer-elim"="false" "no-infs-fp-math"="false"
"no-nans-fp-math"="false" "stack-protector-buffer-size"="8"
"unsafe-fp-math"="false" "use-soft-float"="false" }
attributes #1 = { nounwind readnone }
attributes #2 = { noreturn nounwind }

!llvm.ident = !{!0}

!0 = metadata !{metadata !"clang version 3.5.0 (211898)"}
!1 = metadata !{metadata !2, metadata !2, i64 0}
!2 = metadata !{metadata !"omnipotent char", metadata !3, i64 0}
!3 = metadata !{metadata !"Simple C/C++ TBAA"}


This IR is produced by compiling the following with -ftrapv:

char min; int main() { return min + min; }

-- 
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/20140702/ed371b65/attachment.html>


More information about the llvm-bugs mailing list