[llvm-bugs] [Bug 42661] New: Failure to @llvm.assume lack of unsigned overflow

via llvm-bugs llvm-bugs at lists.llvm.org
Thu Jul 18 01:26:23 PDT 2019


https://bugs.llvm.org/show_bug.cgi?id=42661

            Bug ID: 42661
           Summary: Failure to @llvm.assume lack of unsigned overflow
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Global Analyses
          Assignee: unassignedbugs at nondot.org
          Reporter: lebedev.ri at gmail.com
                CC: llvm-bugs at lists.llvm.org

https://godbolt.org/z/K-Ts7V

int t0(int x) {
    __builtin_assume(x > 0);
    __builtin_assume((3u*unsigned(x)) > unsigned(x));
    return (3 * x) / 2;
}
int t1(int x) {
    __builtin_assume(x > 0);
    __builtin_assume((12u*unsigned(x)) > unsigned(x));
    return (12 * x) / 8;
}

results in 

define dso_local i32 @_Z2t0i(i32) local_unnamed_addr #0 {
  %2 = icmp sgt i32 %0, 0
  tail call void @llvm.assume(i1 %2)
  %3 = mul i32 %0, 3
  %4 = icmp ugt i32 %3, %0
  tail call void @llvm.assume(i1 %4)
  %5 = sdiv i32 %3, 2
  ret i32 %5
}

declare void @llvm.assume(i1) #1

define dso_local i32 @_Z2t1i(i32) local_unnamed_addr #0 {
  %2 = icmp sgt i32 %0, 0
  tail call void @llvm.assume(i1 %2)
  %3 = mul i32 %0, 12
  %4 = icmp ugt i32 %3, %0
  tail call void @llvm.assume(i1 %4)
  %5 = sdiv i32 %3, 8
  ret i32 %5
}

So the 'mul' is both feeding the @llvm.assume (that would signify that it
didn't overflow),
and is being used in the datapath.
I guess this could be due too aggressive CSE?

-- 
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/20190718/9adad71e/attachment-0001.html>


More information about the llvm-bugs mailing list