[PATCH] D28471: Intrinsic::Bitreverse is safe to speculate

Xin Tong via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jan 9 10:08:01 PST 2017


This revision was automatically updated to reflect the committed changes.
Closed by commit rL291456: Intrinsic::Bitreverse is safe to speculate (authored by trentxintong).

Changed prior to commit:
  https://reviews.llvm.org/D28471?vs=83645&id=83646#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D28471

Files:
  llvm/trunk/lib/Analysis/ValueTracking.cpp
  llvm/trunk/test/Transforms/LICM/hoisting.ll


Index: llvm/trunk/test/Transforms/LICM/hoisting.ll
===================================================================
--- llvm/trunk/test/Transforms/LICM/hoisting.ll
+++ llvm/trunk/test/Transforms/LICM/hoisting.ll
@@ -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 @@
 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
+}
Index: llvm/trunk/lib/Analysis/ValueTracking.cpp
===================================================================
--- llvm/trunk/lib/Analysis/ValueTracking.cpp
+++ llvm/trunk/lib/Analysis/ValueTracking.cpp
@@ -3257,6 +3257,7 @@
       case Intrinsic::dbg_value:
         return true;
 
+      case Intrinsic::bitreverse:
       case Intrinsic::bswap:
       case Intrinsic::ctlz:
       case Intrinsic::ctpop:


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D28471.83646.patch
Type: text/x-patch
Size: 1498 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170109/ddf33563/attachment.bin>


More information about the llvm-commits mailing list