diff options
| author | Sanjoy Das <sanjoy@playingwithpointers.com> | 2016-06-14 20:23:16 +0000 | 
|---|---|---|
| committer | Sanjoy Das <sanjoy@playingwithpointers.com> | 2016-06-14 20:23:16 +0000 | 
| commit | d7e8206b58c0a5a6427fa75df734e71692eb31a4 (patch) | |
| tree | 98888ebf864dd4a70ce30414f3716d64e42d86db /llvm | |
| parent | f8b91f8336e6850e0e7107414d61ff99baff57bd (diff) | |
| download | bcm5719-llvm-d7e8206b58c0a5a6427fa75df734e71692eb31a4.tar.gz bcm5719-llvm-d7e8206b58c0a5a6427fa75df734e71692eb31a4.zip  | |
[ValueTracking] Calls to @llvm.assume always return
This change teaches llvm::isGuaranteedToTransferExecutionToSuccessor
that calls to @llvm.assume always terminate.  Most other relevant
intrinsics should be covered by the "CS.onlyReadsMemory() ||
CS.onlyAccessesArgMemory()" bit but we were missing @llvm.assumes
because we state that it clobbers memory.
Added an LICM test case, but this change is not specific to LICM.
llvm-svn: 272703
Diffstat (limited to 'llvm')
| -rw-r--r-- | llvm/lib/Analysis/ValueTracking.cpp | 3 | ||||
| -rw-r--r-- | llvm/test/Transforms/LICM/assume.ll | 19 | 
2 files changed, 20 insertions, 2 deletions
diff --git a/llvm/lib/Analysis/ValueTracking.cpp b/llvm/lib/Analysis/ValueTracking.cpp index 7e09ec74bef..7109ff84b8e 100644 --- a/llvm/lib/Analysis/ValueTracking.cpp +++ b/llvm/lib/Analysis/ValueTracking.cpp @@ -3478,7 +3478,8 @@ bool llvm::isGuaranteedToTransferExecutionToSuccessor(const Instruction *I) {      // but it's consistent with other passes. See http://llvm.org/PR965 .      // FIXME: This isn't aggressive enough; a call which only writes to a      // global is guaranteed to return. -    return CS.onlyReadsMemory() || CS.onlyAccessesArgMemory(); +    return CS.onlyReadsMemory() || CS.onlyAccessesArgMemory() || +           match(I, m_Intrinsic<Intrinsic::assume>());    }    // Other instructions return normally. diff --git a/llvm/test/Transforms/LICM/assume.ll b/llvm/test/Transforms/LICM/assume.ll index 9abf5578287..e426350ce73 100644 --- a/llvm/test/Transforms/LICM/assume.ll +++ b/llvm/test/Transforms/LICM/assume.ll @@ -1,6 +1,7 @@  ; RUN: opt -licm -basicaa < %s -S | FileCheck %s -define void @f(i1 %p) nounwind ssp { +define void @f_0(i1 %p) nounwind ssp { +; CHECK-LABEL: @f_0(  entry:    br label %for.body @@ -31,4 +32,20 @@ for.end104:    ret void  } +define void @f_1(i1 %cond, i32* %ptr) { +; CHECK-LABEL: @f_1( +; CHECK: %val = load i32, i32* %ptr +; CHECK-NEXT:  br label %loop + +entry: +  br label %loop + +loop: +  %x = phi i32 [ 0, %entry ], [ %x.inc, %loop ] +  call void @llvm.assume(i1 %cond) +  %val = load i32, i32* %ptr +  %x.inc = add i32 %x, %val +  br label %loop +} +  declare void @llvm.assume(i1)  | 

