[llvm] 7224cff - Intrinsics: Fix not speculating llvm.fptrunc.round
Matt Arsenault via llvm-commits
llvm-commits at lists.llvm.org
Mon Dec 5 05:39:13 PST 2022
Author: Matt Arsenault
Date: 2022-12-05T08:39:07-05:00
New Revision: 7224cffd62f555d82f6475738e0646c37730cc24
URL: https://github.com/llvm/llvm-project/commit/7224cffd62f555d82f6475738e0646c37730cc24
DIFF: https://github.com/llvm/llvm-project/commit/7224cffd62f555d82f6475738e0646c37730cc24.diff
LOG: Intrinsics: Fix not speculating llvm.fptrunc.round
Move its definition to be with the other FP rounding intrinsics.
Added:
Modified:
llvm/include/llvm/IR/Intrinsics.td
llvm/test/Transforms/SpeculativeExecution/spec-calls.ll
Removed:
################################################################################
diff --git a/llvm/include/llvm/IR/Intrinsics.td b/llvm/include/llvm/IR/Intrinsics.td
index 982f3c985746f..c9fc70639ce57 100644
--- a/llvm/include/llvm/IR/Intrinsics.td
+++ b/llvm/include/llvm/IR/Intrinsics.td
@@ -708,6 +708,11 @@ let IntrProperties = [IntrNoMem, IntrSpeculatable, IntrWillReturn] in {
def int_nearbyint : DefaultAttrsIntrinsic<[llvm_anyfloat_ty], [LLVMMatchType<0>]>;
def int_round : DefaultAttrsIntrinsic<[llvm_anyfloat_ty], [LLVMMatchType<0>]>;
def int_roundeven : DefaultAttrsIntrinsic<[llvm_anyfloat_ty], [LLVMMatchType<0>]>;
+
+ // Truncate a floating point number with a specific rounding mode
+ def int_fptrunc_round : DefaultAttrsIntrinsic<[ llvm_anyfloat_ty ],
+ [ llvm_anyfloat_ty, llvm_metadata_ty ]>;
+
def int_canonicalize : DefaultAttrsIntrinsic<[llvm_anyfloat_ty], [LLVMMatchType<0>],
[IntrNoMem]>;
// Arithmetic fence intrinsic.
@@ -947,11 +952,6 @@ let IntrProperties = [IntrInaccessibleMemOnly, IntrWillReturn] in {
// FIXME: Consider maybe adding intrinsics for sitofp, uitofp.
-// Truncate a floating point number with a specific rounding mode
-def int_fptrunc_round : DefaultAttrsIntrinsic<[ llvm_anyfloat_ty ],
- [ llvm_anyfloat_ty, llvm_metadata_ty ],
- [ IntrNoMem, IntrWillReturn ]>;
-
//===------------------------- Expect Intrinsics --------------------------===//
//
def int_expect : DefaultAttrsIntrinsic<[llvm_anyint_ty],
diff --git a/llvm/test/Transforms/SpeculativeExecution/spec-calls.ll b/llvm/test/Transforms/SpeculativeExecution/spec-calls.ll
index 56d6637b33a6c..6a693b44d5380 100644
--- a/llvm/test/Transforms/SpeculativeExecution/spec-calls.ll
+++ b/llvm/test/Transforms/SpeculativeExecution/spec-calls.ll
@@ -93,3 +93,19 @@ b:
declare i1 @llvm.is.fpclass.f32(float, i32)
declare float @llvm.arithmetic.fence.f32(float)
+
+; CHECK-LABEL: @ifThen_fptrunc_round(
+; CHECK: %round = call half @llvm.fptrunc.round.f16.f32(float %x, metadata !"round.downward")
+; CHECK-NEXT: br i1 true
+define void @ifThen_fptrunc_round(float %x) {
+ br i1 true, label %a, label %b
+
+a:
+ %round = call half @llvm.fptrunc.round.f16.f32(float %x, metadata !"round.downward")
+ br label %b
+
+b:
+ ret void
+}
+
+declare half @llvm.fptrunc.round.f16.f32(float, metadata)
More information about the llvm-commits
mailing list