llvm-6502/test/Transforms/SeparateConstOffsetFromGEP/NVPTX/value-tracking-domtree.ll
Jingyue Wu 19eda5312a [ValueTracking] refactor: extract method haveNoCommonBitsSet
Summary:
Extract method haveNoCommonBitsSet so that we don't have to duplicate this logic in
InstCombine and SeparateConstOffsetFromGEP.

This patch also makes SeparateConstOffsetFromGEP more precise by passing
DominatorTree to computeKnownBits.

Test Plan: value-tracking-domtree.ll that tests ValueTracking indeed leverages dominating conditions

Reviewers: broune, meheff, majnemer

Reviewed By: majnemer

Subscribers: jholewinski, llvm-commits

Differential Revision: http://reviews.llvm.org/D9734

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@237407 91177308-0d34-0410-b5e6-96231b3b80d8
2015-05-14 23:53:19 +00:00

34 lines
866 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 float, float* [[base]], i64 3
ret float* %p
exit:
ret float* null
}