Skip to content

Commit

Permalink
Intrinsics: Fix not speculating llvm.fptrunc.round
Browse files Browse the repository at this point in the history
Move its definition to be with the other FP rounding intrinsics.
  • Loading branch information
arsenm committed Dec 5, 2022
1 parent f32cafe commit 7224cff
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 5 deletions.
10 changes: 5 additions & 5 deletions llvm/include/llvm/IR/Intrinsics.td
Expand Up @@ -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.
Expand Down Expand Up @@ -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],
Expand Down
16 changes: 16 additions & 0 deletions llvm/test/Transforms/SpeculativeExecution/spec-calls.ll
Expand Up @@ -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)

0 comments on commit 7224cff

Please sign in to comment.