[llvm-bugs] [Bug 35069] New: Range does not handle `add` and `ugt` comparison well

via llvm-bugs llvm-bugs at lists.llvm.org
Tue Oct 24 21:18:41 PDT 2017


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

            Bug ID: 35069
           Summary: Range does not handle `add` and `ugt` comparison well
           Product: libraries
           Version: 5.0
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Scalar Optimizations
          Assignee: unassignedbugs at nondot.org
          Reporter: yyc1992 at gmail.com
                CC: llvm-bugs at lists.llvm.org

Reproduced with following IR.

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

define void @f(i64*) {
  %2 = load i64, i64* %0, align 8, !range !0
  %3 = add i64 %2, -1
  %4 = icmp ugt i64 %3, 1000
  br i1 %4, label %L1, label %L2

L1:
  tail call void @g()
  unreachable

L2:
  ret void
}

declare void @g()

!0 = !{i64 2, i64 100}
```

I believe that the function should be optmized to `ret void` since the `icmp`
should always be `false` for the specified range. However, `opt` with
`-instcombine`, `-instsimplify` or just `-O3` does nothing to the `icmp` or the
branch.

Removing the `add` (and make `icmp` take the load value directly) works as
expected as well as replacing the `ugt` with `sgt` even though it shouldn't
make a difference in the value range....

-- 
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/20171025/7e65ca58/attachment.html>


More information about the llvm-bugs mailing list