[PATCH] D12266: Assume intrinsic handling in globalopt

Piotr Padlewski via llvm-commits llvm-commits at lists.llvm.org
Sat Aug 22 21:00:36 PDT 2015


Prazek created this revision.
Prazek added reviewers: nlewycky, rsmith, majnemer.
Prazek added a subscriber: llvm-commits.

http://reviews.llvm.org/D12266

Files:
  lib/Transforms/IPO/GlobalOpt.cpp
  test/Transforms/GlobalOpt/assume.ll

Index: test/Transforms/GlobalOpt/assume.ll
===================================================================
--- /dev/null
+++ test/Transforms/GlobalOpt/assume.ll
@@ -0,0 +1,21 @@
+; RUN: opt -S -globalopt < %s | FileCheck %s
+
+; CHECK: @tmp = global i32 42
+
+ at llvm.global_ctors = appending global [1 x { i32, void ()* }] [{ i32, void ()* } { i32 65535, void ()* @_GLOBAL__I_a }]
+ at tmp = global i32 0
+
+define i32 @TheAnswerToLifeTheUniverseAndEverything() {
+  ret i32 42
+}
+
+define void @_GLOBAL__I_a() personality i8* undef {
+enter:
+  %tmp1 = call i32 @TheAnswerToLifeTheUniverseAndEverything()
+  store i32 %tmp1, i32* @tmp
+  %cmp = icmp eq i32 %tmp1, 42
+  call void @llvm.assume(i1 %cmp)
+  ret void
+}
+
+declare void @llvm.assume(i1)
Index: lib/Transforms/IPO/GlobalOpt.cpp
===================================================================
--- lib/Transforms/IPO/GlobalOpt.cpp
+++ lib/Transforms/IPO/GlobalOpt.cpp
@@ -2504,6 +2504,10 @@
           // Continue even if we do nothing.
           ++CurInst;
           continue;
+        } else if (II->getIntrinsicID() == Intrinsic::assume) {
+          DEBUG(dbgs() << "Skipping assume intrinsic.\n");
+          ++CurInst;
+          continue;
         }
 
         DEBUG(dbgs() << "Unknown intrinsic. Can not evaluate.\n");


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D12266.32914.patch
Type: text/x-patch
Size: 1295 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150823/0c4f4ded/attachment.bin>


More information about the llvm-commits mailing list