[llvm] 8e4ae60 - [Tests] Add tests for non-speculatable ephemeral values
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Wed Oct 20 14:34:25 PDT 2021
Author: Nikita Popov
Date: 2021-10-20T23:33:36+02:00
New Revision: 8e4ae603d6ec7658df86302d122fb24968524164
URL: https://github.com/llvm/llvm-project/commit/8e4ae603d6ec7658df86302d122fb24968524164
DIFF: https://github.com/llvm/llvm-project/commit/8e4ae603d6ec7658df86302d122fb24968524164.diff
LOG: [Tests] Add tests for non-speculatable ephemeral values
The loads in these examples are currently not considered ephemeral
because they are not speculatable.
Added:
Modified:
llvm/test/Transforms/Inline/ephemeral.ll
llvm/test/Transforms/SimplifyCFG/unprofitable-pr.ll
Removed:
################################################################################
diff --git a/llvm/test/Transforms/Inline/ephemeral.ll b/llvm/test/Transforms/Inline/ephemeral.ll
index 7d9bd7130fa3a..f47c349cb517b 100644
--- a/llvm/test/Transforms/Inline/ephemeral.ll
+++ b/llvm/test/Transforms/Inline/ephemeral.ll
@@ -1,11 +1,12 @@
; RUN: opt -S -inline %s -debug-only=inline-cost 2>&1 | FileCheck %s
; REQUIRES: asserts
-; Only the load and ret should be included in the instruction count, not
-; the instructions feeding the assume.
-; CHECK: NumInstructions: 2
@a = global i32 4
+; Only the load and ret should be included in the instruction count, not
+; the instructions feeding the assume.
+; CHECK: Analyzing call of inner...
+; CHECK: NumInstructions: 2
define i32 @inner(i8* %y) {
%a1 = load volatile i32, i32* @a
@@ -25,8 +26,20 @@ define i32 @inner(i8* %y) {
ret i32 %a1
}
+; TODO: The load should be considered ephemeral here, even though it is not
+; speculatable.
+; CHECK: Analyzing call of inner2...
+; CHECK: NumInstructions: 2
+define void @inner2(i8* %y) {
+ %v = load i8, i8* %y
+ %c = icmp eq i8 %v, 42
+ call void @llvm.assume(i1 %c)
+ ret void
+}
+
define i32 @outer(i8* %y) optsize {
%r = call i32 @inner(i8* %y)
+ call void @inner2(i8* %y)
ret i32 %r
}
diff --git a/llvm/test/Transforms/SimplifyCFG/unprofitable-pr.ll b/llvm/test/Transforms/SimplifyCFG/unprofitable-pr.ll
index 8d227cf989741..af918657b5701 100644
--- a/llvm/test/Transforms/SimplifyCFG/unprofitable-pr.ll
+++ b/llvm/test/Transforms/SimplifyCFG/unprofitable-pr.ll
@@ -232,3 +232,58 @@ false2: ; preds = %true1
store volatile i64 3, i64* %ptr, align 8
ret void
}
+
+; TODO: The load should be considered ephemeral here, even though it is not
+; speculatable.
+define void @test_non_speculatable(i1 %c, i64* align 1 %ptr, i8* %ptr2) local_unnamed_addr #0 {
+; CHECK-LABEL: @test_non_speculatable(
+; CHECK-NEXT: br i1 [[C:%.*]], label [[TRUE1:%.*]], label [[FALSE1:%.*]]
+; CHECK: true1:
+; CHECK-NEXT: [[V:%.*]] = load i8, i8* [[PTR2:%.*]], align 1
+; CHECK-NEXT: [[C2:%.*]] = icmp eq i8 [[V]], 42
+; CHECK-NEXT: call void @llvm.assume(i1 [[C2]])
+; CHECK-NEXT: store volatile i64 0, i64* [[PTR:%.*]], align 8
+; CHECK-NEXT: store volatile i64 -1, i64* [[PTR]], align 8
+; CHECK-NEXT: store volatile i64 -1, i64* [[PTR]], align 8
+; CHECK-NEXT: store volatile i64 -1, i64* [[PTR]], align 8
+; CHECK-NEXT: store volatile i64 -1, i64* [[PTR]], align 8
+; CHECK-NEXT: store volatile i64 -1, i64* [[PTR]], align 8
+; CHECK-NEXT: br i1 [[C]], label [[TRUE2:%.*]], label [[FALSE2:%.*]]
+; CHECK: false1:
+; CHECK-NEXT: store volatile i64 1, i64* [[PTR]], align 4
+; CHECK-NEXT: br label [[TRUE1]]
+; CHECK: common.ret:
+; CHECK-NEXT: ret void
+; CHECK: true2:
+; CHECK-NEXT: store volatile i64 2, i64* [[PTR]], align 8
+; CHECK-NEXT: br label [[COMMON_RET:%.*]]
+; CHECK: false2:
+; CHECK-NEXT: store volatile i64 3, i64* [[PTR]], align 8
+; CHECK-NEXT: br label [[COMMON_RET]]
+;
+ br i1 %c, label %true1, label %false1
+
+true1: ; preds = %false1, %0
+ %v = load i8, i8* %ptr2
+ %c2 = icmp eq i8 %v, 42
+ call void @llvm.assume(i1 %c2)
+ store volatile i64 0, i64* %ptr, align 8
+ store volatile i64 -1, i64* %ptr, align 8
+ store volatile i64 -1, i64* %ptr, align 8
+ store volatile i64 -1, i64* %ptr, align 8
+ store volatile i64 -1, i64* %ptr, align 8
+ store volatile i64 -1, i64* %ptr, align 8
+ br i1 %c, label %true2, label %false2
+
+false1: ; preds = %0
+ store volatile i64 1, i64* %ptr, align 4
+ br label %true1
+
+true2: ; preds = %true1
+ store volatile i64 2, i64* %ptr, align 8
+ ret void
+
+false2: ; preds = %true1
+ store volatile i64 3, i64* %ptr, align 8
+ ret void
+}
More information about the llvm-commits
mailing list