-
Notifications
You must be signed in to change notification settings - Fork 14.3k
Fix bug with -ffp-contract=fast-honor-pragmas #104857
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
Merged
Merged
Changes from 1 commit
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
clang/test/CodeGen/ffp-contract-fast-honor-pramga-option.cpp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
// RUN: %clang_cc1 -O3 -ffp-contract=fast-honor-pragmas -triple %itanium_abi_triple -emit-llvm -o - %s | FileCheck %s | ||
|
||
float fp_contract_1(float a, float b, float c) { | ||
// CHECK-LABEL: fp_contract_1fff( | ||
// CHECK: fmul contract float | ||
// CHECK: fadd contract float | ||
return a * b + c; | ||
} | ||
|
||
float fp_contract_2(float a, float b, float c) { | ||
// CHECK-LABEL: fp_contract_2fff( | ||
// CHECK: fmul contract float | ||
// CHECK: fsub contract float | ||
return a * b - c; | ||
} | ||
|
||
void fp_contract_3(float *a, float b, float c) { | ||
// CHECK-LABEL: fp_contract_3Pfff( | ||
// CHECK: fmul contract float | ||
// CHECK: fadd contract float | ||
a[0] += b * c; | ||
} | ||
|
||
void fp_contract_4(float *a, float b, float c) { | ||
// CHECK-LABEL: fp_contract_4Pfff( | ||
// CHECK: fmul contract float | ||
// CHECK: fsub contract float | ||
a[0] -= b * c; | ||
} | ||
|
||
float fp_contract_5(float a, float b, float c) { | ||
// CHECK-LABEL: fp_contract_5fff( | ||
// CHECK: fmul contract float | ||
// CHECK: fadd contract float | ||
float t = a * b; | ||
return t + c; | ||
} | ||
151 changes: 151 additions & 0 deletions
151
clang/test/CodeGen/ffp-contract-fhp-pragma-override.cpp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,151 @@ | ||
// RUN: %clang_cc1 -O3 -ffp-contract=fast-honor-pragmas -triple %itanium_abi_triple -emit-llvm -o - %s | FileCheck %s | ||
|
||
float fp_contract_on_1(float a, float b, float c) { | ||
// CHECK-LABEL: fp_contract_on_1fff( | ||
// CHECK: call float @llvm.fmuladd.f32(float {{.*}}, float {{.*}}, float {{.*}}) | ||
#pragma STDC FP_CONTRACT ON | ||
return a * b + c; | ||
} | ||
|
||
float fp_contract_on_2(float a, float b, float c) { | ||
// CHECK-LABEL: fp_contract_on_2fff( | ||
// CHECK: fmul float | ||
// CHECK: fadd float | ||
#pragma STDC FP_CONTRACT ON | ||
float t = a * b; | ||
return t + c; | ||
} | ||
|
||
float fp_contract_off_1(float a, float b, float c) { | ||
// CHECK-LABEL: fp_contract_off_1fff( | ||
// CHECK: fmul float | ||
// CHECK: fadd float | ||
#pragma STDC FP_CONTRACT OFF | ||
return a * b + c; | ||
} | ||
|
||
float fp_contract_off_2(float a, float b, float c) { | ||
// CHECK-LABEL: fp_contract_off_2fff( | ||
// CHECK: fmul float | ||
// CHECK: fadd float | ||
#pragma STDC FP_CONTRACT OFF | ||
float t = a * b; | ||
return t + c; | ||
} | ||
|
||
float fp_contract_default_1(float a, float b, float c) { | ||
// CHECK-LABEL: fp_contract_default_1fff( | ||
// CHECK: fmul contract float | ||
// CHECK: fadd contract float | ||
#pragma STDC FP_CONTRACT DEFAULT | ||
return a * b + c; | ||
} | ||
|
||
float fp_contract_default_2(float a, float b, float c) { | ||
// CHECK-LABEL: fp_contract_default_2fff( | ||
// CHECK: fmul contract float | ||
// CHECK: fadd contract float | ||
#pragma STDC FP_CONTRACT DEFAULT | ||
float t = a * b; | ||
return t + c; | ||
} | ||
|
||
float fp_contract_clang_on_1(float a, float b, float c) { | ||
// CHECK-LABEL: fp_contract_clang_on_1fff( | ||
// CHECK: call float @llvm.fmuladd.f32(float {{.*}}, float {{.*}}, float {{.*}}) | ||
#pragma clang fp contract(on) | ||
return a * b + c; | ||
} | ||
|
||
float fp_contract_clang_on_2(float a, float b, float c) { | ||
// CHECK-LABEL: fp_contract_clang_on_2fff( | ||
// CHECK: fmul float | ||
// CHECK: fadd float | ||
#pragma clang fp contract(on) | ||
float t = a * b; | ||
return t + c; | ||
} | ||
|
||
float fp_contract_clang_off_1(float a, float b, float c) { | ||
// CHECK-LABEL: fp_contract_clang_off_1fff( | ||
// CHECK: fmul float | ||
// CHECK: fadd float | ||
#pragma clang fp contract(off) | ||
return a * b + c; | ||
} | ||
|
||
float fp_contract_clang_off_2(float a, float b, float c) { | ||
// CHECK-LABEL: fp_contract_clang_off_2fff( | ||
// CHECK: fmul float | ||
// CHECK: fadd float | ||
#pragma clang fp contract(off) | ||
float t = a * b; | ||
return t + c; | ||
} | ||
|
||
float fp_contract_clang_fast_1(float a, float b, float c) { | ||
// CHECK-LABEL: fp_contract_clang_fast_1fff( | ||
// CHECK: fmul contract float | ||
// CHECK: fadd contract float | ||
#pragma clang fp contract(fast) | ||
return a * b + c; | ||
} | ||
|
||
float fp_contract_clang_fast_2(float a, float b, float c) { | ||
// CHECK-LABEL: fp_contract_clang_fast_2fff( | ||
// CHECK: fmul contract float | ||
// CHECK: fadd contract float | ||
#pragma clang fp contract(fast) | ||
float t = a * b; | ||
return t + c; | ||
} | ||
|
||
#pragma STDC FP_CONTRACT ON | ||
|
||
float fp_contract_global_on_1(float a, float b, float c) { | ||
// CHECK-LABEL: fp_contract_global_on_1fff( | ||
// CHECK: call float @llvm.fmuladd.f32(float {{.*}}, float {{.*}}, float {{.*}}) | ||
return a * b + c; | ||
} | ||
|
||
float fp_contract_global_on_2(float a, float b, float c) { | ||
// CHECK-LABEL: fp_contract_global_on_2fff( | ||
// CHECK: fmul float | ||
// CHECK: fadd float | ||
float t = a * b; | ||
return t + c; | ||
} | ||
|
||
#pragma STDC FP_CONTRACT OFF | ||
|
||
float fp_contract_global_off_1(float a, float b, float c) { | ||
// CHECK-LABEL: fp_contract_global_off_1fff( | ||
// CHECK: fmul float | ||
// CHECK: fadd float | ||
return a * b + c; | ||
} | ||
|
||
float fp_contract_global_off_2(float a, float b, float c) { | ||
// CHECK-LABEL: fp_contract_global_off_2fff( | ||
// CHECK: fmul float | ||
// CHECK: fadd float | ||
float t = a * b; | ||
return t + c; | ||
} | ||
|
||
#pragma STDC FP_CONTRACT DEFAULT | ||
|
||
float fp_contract_global_default_1(float a, float b, float c) { | ||
// CHECK-LABEL: fp_contract_global_default_1fff( | ||
// CHECK: fmul contract float | ||
// CHECK: fadd contract float | ||
return a * b + c; | ||
} | ||
|
||
float fp_contract_global_default_2(float a, float b, float c) { | ||
// CHECK-LABEL: fp_contract_global_default_2fff( | ||
// CHECK: fmul contract float | ||
// CHECK: fadd contract float | ||
float t = a * b; | ||
return t + c; | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. And a newline here as well. |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add a newline to the end of the file.