1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-19 11:02:59 +02:00
llvm-mirror/test/Transforms/InstCombine/convergent.ll
Justin Lebar 7e369d0dca [attrs] Handle convergent CallSites.
Summary:
Previously we had a notion of convergent functions but not of convergent
calls.  This is insufficient to correctly analyze calls where the target
is unknown, e.g. indirect calls.

Now a call is convergent if it targets a known-convergent function, or
if it's explicitly marked as convergent.  As usual, we can remove
convergent where we can prove that no convergent operations are
performed in the call.

Originally landed as r261544, then reverted in r261544 for (incidental)
build breakage.  Re-landed here with no changes.

Reviewers: chandlerc, jingyue

Subscribers: llvm-commits, tra, jhen, hfinkel

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

llvm-svn: 263481
2016-03-14 20:18:54 +00:00

34 lines
804 B
LLVM

; RUN: opt -instcombine -S < %s | FileCheck %s
declare i32 @k() convergent
declare i32 @f()
define i32 @extern() {
; Convergent attr shouldn't be removed here; k is convergent.
; CHECK: call i32 @k() [[CONVERGENT_ATTR:#[0-9]+]]
%a = call i32 @k() convergent
ret i32 %a
}
define i32 @extern_no_attr() {
; Convergent attr shouldn't be added here, even though k is convergent.
; CHECK: call i32 @k(){{$}}
%a = call i32 @k()
ret i32 %a
}
define i32 @no_extern() {
; Convergent should be removed here, as the target is convergent.
; CHECK: call i32 @f(){{$}}
%a = call i32 @f() convergent
ret i32 %a
}
define i32 @indirect_call(i32 ()* %f) {
; CHECK call i32 %f() [[CONVERGENT_ATTR]]
%a = call i32 %f() convergent
ret i32 %a
}
; CHECK: [[CONVERGENT_ATTR]] = { convergent }