Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Backport to 14] fpbuiltin-max-error support #2421

Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion lib/SPIRV/SPIRVUtil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -767,7 +767,12 @@ CallInst *mutateCallInst(
InstName, TakeFuncName);
NewCI->setDebugLoc(CI->getDebugLoc());
NewCI->copyMetadata(*CI);
NewCI->setAttributes(CI->getAttributes());
NewCI->setAttributes(CI->getAttributes());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it a cherry-pick or a stand-alone fix?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a stand-alone fix

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also there were spaces at the end previously

NewCI->setTailCall(CI->isTailCall());
if (CI->hasFnAttr("fpbuiltin-max-error")) {
auto Attr = CI->getFnAttr("fpbuiltin-max-error");
NewCI->addFnAttr(Attr);
}
LLVM_DEBUG(dbgs() << " => " << *NewCI << '\n');
CI->replaceAllUsesWith(NewCI);
CI->eraseFromParent();
Expand Down
21 changes: 8 additions & 13 deletions test/extensions/INTEL/SPV_INTEL_fp_max_error/IntelFPMaxError.ll
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@
; CHECK-SPIRV: Name [[#T31:]] "t31"
; CHECK-SPIRV: Name [[#T32:]] "t32"
; CHECK-SPIRV: Name [[#T33:]] "t33"
; CHECK-SPIRV: Name [[#T34:]] "t34"

; CHECK-SPIRV: Decorate [[#T3]] FPMaxErrorDecorationINTEL 1056964608
; CHECK-SPIRV: Decorate [[#T4]] FPMaxErrorDecorationINTEL 1065353216
Expand Down Expand Up @@ -75,8 +74,7 @@
; CHECK-SPIRV: Decorate [[#T30]] FPMaxErrorDecorationINTEL 1082130432
; CHECK-SPIRV: Decorate [[#T31]] FPMaxErrorDecorationINTEL 1082130432
; CHECK-SPIRV: Decorate [[#T32]] FPMaxErrorDecorationINTEL 1082130432
; CHECK-SPIRV: Decorate [[#T33]] FPMaxErrorDecorationINTEL 1082130432
; CHECK-SPIRV: Decorate [[#T34]] FPMaxErrorDecorationINTEL 1166016512
; CHECK-SPIRV: Decorate [[#T33]] FPMaxErrorDecorationINTEL 1166016512

; CHECK-SPIRV: 3 TypeFloat [[#FTYPE:]] 32

Expand Down Expand Up @@ -113,12 +111,11 @@
; CHECK-SPIRV: ExtInst [[#FTYPE]] [[#T31]] [[#OCLEXTID]] ldexp
; CHECK-SPIRV: ExtInst [[#FTYPE]] [[#T32]] [[#OCLEXTID]] pow
; CHECK-SPIRV: ExtInst [[#FTYPE]] [[#T33]] [[#OCLEXTID]] hypot
; CHECK-SPIRV: ExtInst [[#FTYPE]] [[#T34]] [[#OCLEXTID]] hypot

target datalayout = "e-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-n8:16:32:64"
target triple = "spir64-unknown-unknown"

define void @test_fp_max_error_decoration(float %f1, float %f2, float %f3) {
define void @test_fp_max_error_decoration(float %f1, float %f2, float %f3, i32 %f4) {
entry:
; CHECK-LLVM-NOT: fadd float %f1, %f2, !fpbuiltin-max-error
; CHECK-LLVM-NOT: fsub float %f1, %f2, !fpbuiltin-max-error
Expand Down Expand Up @@ -187,16 +184,14 @@ entry:
%t29 = call float @llvm.fpbuiltin.erfc.f32(float %f1) #2

; CHECK-LLVM: call spir_func float @_Z5atan2ff(float %f1, float %f2) #[[#AT4:]]
; CHECK-LLVM: call spir_func float @_Z5ldexpff(float %f1, float %f2) #[[#AT4]]
; CHECK-LLVM: call spir_func float @_Z5ldexpfi(float %f1, i32 %f4) #[[#AT4]]
; CHECK-LLVM: call spir_func float @_Z3powff(float %f1, float %f2) #[[#AT4]]
; CHECK-LLVM: call spir_func float @_Z5hypotff(float %f1, float %f2) #[[#AT4]]
%t30 = call float @llvm.fpbuiltin.atan2.f32(float %f1, float %f2) #3
%t31 = call float @llvm.fpbuiltin.ldexp.f32(float %f1, float %f2) #3
%t31 = call float @llvm.fpbuiltin.ldexp.f32.i32(float %f1, i32 %f4) #3
%t32 = call float @llvm.fpbuiltin.pow.f32(float %f1, float %f2) #3
%t33 = call float @llvm.fpbuiltin.hypot.f32(float %f1, float %f2) #3


; CHECK-LLVM: call spir_func float @_Z5hypotff(float %f1, float %f2) #[[#AT5:]]
%t34 = call float @llvm.fpbuiltin.hypot.f32(float %f1, float %f2) #4
%t33 = call float @llvm.fpbuiltin.hypot.f32(float %f1, float %f2) #4

ret void
}
Expand Down Expand Up @@ -235,7 +230,7 @@ declare float @llvm.fpbuiltin.erfc.f32(float)
declare float @llvm.fpbuiltin.atan2.f32(float, float)
declare float @llvm.fpbuiltin.hypot.f32(float, float)
declare float @llvm.fpbuiltin.pow.f32(float, float)
declare float @llvm.fpbuiltin.ldexp.f32(float, float)
declare float @llvm.fpbuiltin.ldexp.f32.i32(float, i32)

; CHECK-LLVM: attributes #[[#AT3]] = {{{.*}} "fpbuiltin-max-error"="2.5{{0+}}" {{.*}}}
; CHECK-LLVM: attributes #[[#AT4]] = {{{.*}} "fpbuiltin-max-error"="4.0{{0+}}" {{.*}}}
Expand All @@ -247,4 +242,4 @@ attributes #0 = { "fpbuiltin-max-error"="0.5" }
attributes #1 = { "fpbuiltin-max-error"="1.0" }
attributes #2 = { "fpbuiltin-max-error"="2.5" }
attributes #3 = { "fpbuiltin-max-error"="4.0" }
attributes #4 = { "fpbuiltin-max-error"="4096.0" }
attributes #4 = { "fpbuiltin-max-error"="4096.0" }