[llvm-bugs] [Bug 44403] New: Folding 'gep p, (q - p)' to q should check it is never used for loads & stores

via llvm-bugs llvm-bugs at lists.llvm.org
Sun Dec 29 12:16:26 PST 2019


            Bug ID: 44403
           Summary: Folding 'gep p, (q - p)' to q should check it is never
                    used for loads & stores
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: Scalar Optimizations
          Assignee: unassignedbugs at nondot.org
          Reporter: juneyoung.lee at sf.snu.ac.kr
                CC: llvm-bugs at lists.llvm.org


$ cat gep.ll 
define i8* @f(i8* %p, i8* %q) {
  %i = ptrtoint i8* %p to i64
  %j = ptrtoint i8* %q to i64
  %diff = sub i64 %j, %i
  %p2 = getelementptr i8, i8* %p, i64 %diff
  ret i8* %p2
$ opt -instcombine gep.ll -S -o -
; ModuleID = 'gep.ll'
source_filename = "gep.ll"
define i8* @f(i8* %p, i8* %q) {
  ret i8* %q

According to the GEP document:
Replacing ‘gep p, (q - p)’ with q is invalid when it is used by memory access
InstCombine and InstSimplify both do this.

`llc gep.ll -o -` emits an optimized assembly, so SelDag or MIR seem to already
have optimizations for these this pattern if my understanding is correct?

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/20191229/8ce3b3ab/attachment.html>

More information about the llvm-bugs mailing list