1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-21 20:12:56 +02:00
llvm-mirror/test/Transforms/SeparateConstOffsetFromGEP/NVPTX/value-tracking-domtree.ll
Jingyue Wu 7505d46dee [SeparateConstOffsetFromGEP] strengthen the inbounds attribute
We used to be over-conservative about preserving inbounds. Actually, the second
GEP (which applies the constant offset) can inherit the inbounds attribute of
the original GEP, because the resultant pointer is equivalent to that of the
original GEP. For example,

  x  = GEP inbounds a, i+5
    =>
  y = GEP a, i               // inbounds removed
  x = GEP inbounds y, 5      // inbounds preserved

llvm-svn: 244937
2015-08-13 18:48:49 +00:00

34 lines
875 B
LLVM

; RUN: opt < %s -separate-const-offset-from-gep -value-tracking-dom-conditions -reassociate-geps-verify-no-dead-code -S | FileCheck %s
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
target triple = "nvptx64-unknown-unknown"
; if (i == 4)
; p = &input[i | 3];
;
; =>
;
; if (i == 4) {
; base = &input[i];
; p = &base[3];
; }
;
; We should treat (i | 3) as (i + 3) because i is guaranteed to be 4, which
; does not share any set bits with 3.
define float* @guarded_or(float* %input, i64 %i) {
; CHECK-LABEL: @guarded_or(
entry:
%is4 = icmp eq i64 %i, 4
br i1 %is4, label %then, label %exit
then:
%or = or i64 %i, 3
%p = getelementptr inbounds float, float* %input, i64 %or
; CHECK: [[base:[^ ]+]] = getelementptr float, float* %input, i64 %i
; CHECK: getelementptr inbounds float, float* [[base]], i64 3
ret float* %p
exit:
ret float* null
}