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

            Bug ID: 28562
           Summary: GVN ignores inbounds of getelementptr
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: Scalar Optimizations
          Assignee: unassignedb...@nondot.org
          Reporter: kyoo...@gmail.com
                CC: david.majne...@gmail.com, dber...@dberlin.org,
                    listm...@philipreames.com, llvm-bugs@lists.llvm.org,
                    nunoplo...@sapo.pt, san...@playingwithpointers.com
    Classification: Unclassified

GVN ignores the inbounds keyword of getelementptr instructions.

As a consequence, it may replace a GEP instruction without inbounds with
another GEP with inbounds.

Running 'opt -gvn' for the source code below produces the following result:


source:

define i32* @foo(i32* %a) {
  %x1 = getelementptr inbounds i32, i32* %a, i32 10
  %x2 = getelementptr i32, i32* %a, i32 10
  ret i32* %x2
}

result:

define i32* @foo(i32* %a) {
  %x1 = getelementptr inbounds i32, i32* %a, i32 10
  ret i32* %x1
}


I think foo's behavior is changed, since the GEP with inbounds can be a poison
value.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to