1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-19 02:52:53 +02:00

Intrinsic::Bitreverse is safe to speculate

Summary: Intrinsic::Bitreverse is safe to speculate

Reviewers: hfinkel, mkuper, arsenm, jmolloy

Subscribers: llvm-commits

Differential Revision: https://reviews.llvm.org/D28471

llvm-svn: 291456
This commit is contained in:
Xin Tong 2017-01-09 17:57:08 +00:00
parent c5b243c780
commit 9aa14f6869
2 changed files with 28 additions and 0 deletions

View File

@ -3257,6 +3257,7 @@ bool llvm::isSafeToSpeculativelyExecute(const Value *V,
case Intrinsic::dbg_value:
return true;
case Intrinsic::bitreverse:
case Intrinsic::bswap:
case Intrinsic::ctlz:
case Intrinsic::ctpop:

View File

@ -5,6 +5,8 @@
declare void @foo()
declare i32 @llvm.bitreverse.i32(i32)
; This testcase tests for a problem where LICM hoists
; potentially trapping instructions when they are not guaranteed to execute.
define i32 @test1(i1 %c) {
@ -122,3 +124,28 @@ then: ; preds = %tailrecurse
ifend: ; preds = %tailrecurse
ret { i32*, i32 } %d
}
; CHECK: define i32 @hoist_bitreverse(i32)
; CHECK: bitreverse
; CHECK: br label %header
define i32 @hoist_bitreverse(i32) {
br label %header
header:
%sum = phi i32 [ 0, %1 ], [ %5, %latch ]
%2 = phi i32 [ 0, %1 ], [ %6, %latch ]
%3 = icmp slt i32 %2, 1024
br i1 %3, label %body, label %return
body:
%4 = call i32 @llvm.bitreverse.i32(i32 %0)
%5 = add i32 %sum, %4
br label %latch
latch:
%6 = add nsw i32 %2, 1
br label %header
return:
ret i32 %sum
}