[PATCH] D51814: Set cost of invariant group intrinsics to 0
Piotr Padlewski via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Sep 7 15:31:09 PDT 2018
This revision was automatically updated to reflect the committed changes.
Closed by commit rL341725: Set cost of invariant group intrinsics to 0 (authored by Prazek, committed by ).
Changed prior to commit:
https://reviews.llvm.org/D51814?vs=164509&id=164529#toc
Repository:
rL LLVM
https://reviews.llvm.org/D51814
Files:
llvm/trunk/include/llvm/Analysis/TargetTransformInfoImpl.h
llvm/trunk/test/Transforms/Inline/launder.invariant.group.ll
Index: llvm/trunk/include/llvm/Analysis/TargetTransformInfoImpl.h
===================================================================
--- llvm/trunk/include/llvm/Analysis/TargetTransformInfoImpl.h
+++ llvm/trunk/include/llvm/Analysis/TargetTransformInfoImpl.h
@@ -158,6 +158,8 @@
case Intrinsic::dbg_label:
case Intrinsic::invariant_start:
case Intrinsic::invariant_end:
+ case Intrinsic::launder_invariant_group:
+ case Intrinsic::strip_invariant_group:
case Intrinsic::lifetime_start:
case Intrinsic::lifetime_end:
case Intrinsic::objectsize:
Index: llvm/trunk/test/Transforms/Inline/launder.invariant.group.ll
===================================================================
--- llvm/trunk/test/Transforms/Inline/launder.invariant.group.ll
+++ llvm/trunk/test/Transforms/Inline/launder.invariant.group.ll
@@ -1,13 +1,13 @@
; RUN: opt -S -inline < %s | FileCheck %s
; RUN: opt -S -O3 < %s | FileCheck %s
+; RUN: opt -S -inline -inline-threshold=1 < %s | FileCheck %s
+
+%struct.A = type <{ i32 (...)**, i32, [4 x i8] }>
; This test checks if value returned from the launder is considered aliasing
; with its argument. Due to bug caused by handling launder in capture tracking
; sometimes it would be considered noalias.
-
-%struct.A = type <{ i32 (...)**, i32, [4 x i8] }>
-
-; CHECK: define i32 @bar(%struct.A* noalias
+; CHECK-LABEL: define i32 @bar(%struct.A* noalias
define i32 @bar(%struct.A* noalias) {
; CHECK-NOT: noalias
%2 = bitcast %struct.A* %0 to i8*
@@ -28,4 +28,32 @@
ret i32 %2
}
+
+; This test checks if invariant group intrinsics have zero cost for inlining.
+; CHECK-LABEL: define i8* @caller(i8*
+define i8* @caller(i8* %p) {
+; CHECK-NOT: call i8* @lot_of_launders_and_strips
+ %a1 = call i8* @lot_of_launders_and_strips(i8* %p)
+ %a2 = call i8* @lot_of_launders_and_strips(i8* %a1)
+ %a3 = call i8* @lot_of_launders_and_strips(i8* %a2)
+ %a4 = call i8* @lot_of_launders_and_strips(i8* %a3)
+ ret i8* %a4
+}
+
+define i8* @lot_of_launders_and_strips(i8* %p) {
+ %a1 = call i8* @llvm.launder.invariant.group.p0i8(i8* %p)
+ %a2 = call i8* @llvm.launder.invariant.group.p0i8(i8* %a1)
+ %a3 = call i8* @llvm.launder.invariant.group.p0i8(i8* %a2)
+ %a4 = call i8* @llvm.launder.invariant.group.p0i8(i8* %a3)
+
+ %s1 = call i8* @llvm.strip.invariant.group.p0i8(i8* %a4)
+ %s2 = call i8* @llvm.strip.invariant.group.p0i8(i8* %s1)
+ %s3 = call i8* @llvm.strip.invariant.group.p0i8(i8* %s2)
+ %s4 = call i8* @llvm.strip.invariant.group.p0i8(i8* %s3)
+
+ ret i8* %s4
+}
+
+
declare i8* @llvm.launder.invariant.group.p0i8(i8*)
+declare i8* @llvm.strip.invariant.group.p0i8(i8*)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D51814.164529.patch
Type: text/x-patch
Size: 2664 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180907/86b35a95/attachment.bin>
More information about the llvm-commits
mailing list