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

            Bug ID: 47243
           Summary: Instcombine drops range information when combining
                    inttoptr with load
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Scalar Optimizations
          Assignee: [email protected]
          Reporter: [email protected]
                CC: [email protected]

Created attachment 23865
  --> https://bugs.llvm.org/attachment.cgi?id=23865&action=edit
Reproducer

When instcombine replaces inttoptr(load intTy) to (load ptrTy) it drops the
range information attached to the load.
More precisely, it replaces the range information with an inferior metadata.

The problem may lay into what the range information can represent, but we
should fix that one way or another as this may result in suboptimal code.

* Example *

Consider the following snippet:
```
define float* @test5_range(i64* %ptr) {
entry:
  %val = load i64, i64* %ptr, !range !{i64 64, i64 65536}
  %valptr = inttoptr i64 %val to float*
  ret float* %valptr
}
```

The returned pointer is known to be between address 64 and address 65536.

After instcombine however, this information is lost and instead we have a less
rich information that the pointer is non-null:
```
define float* @test5_range(i64* %ptr) {
entry:
  %0 = bitcast i64* %ptr to float**
  %val1 = load float*, float** %0, align 4, !nonnull !0
  ret float* %val1
}
```

* To Reproduce *

opt -S  -instcombine ~/Downloads/instcombine_range.ll  -o -

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to