-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[SimplifyLibCalls] Constant fold remquo
#99647
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 all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
3ca0346
[SimplfiyLibCalls] Constant fold remquo
dtcxzyw 5034ef4
[SimplifyLibCalls] Fix typo
dtcxzyw 96a0ef3
[SimplifyLibCalls] Address review comments.
dtcxzyw 7050286
[SimplifyLibCalls] Put remquol variants into separate files. NFC.
dtcxzyw f6adf3b
[SimplifyLibCalls] Add more tests. NFC.
dtcxzyw 4584775
[SimplifyLibCalls] Format code. NFC.
dtcxzyw d171826
[SimplifyLibCalls] Address review comments. NFC.
dtcxzyw 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
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
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,139 @@ | ||
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 5 | ||
; RUN: opt < %s -passes=instcombine -S | FileCheck %s | ||
|
||
define float @remquo_f32(ptr %quo) { | ||
; CHECK-LABEL: define float @remquo_f32( | ||
; CHECK-SAME: ptr [[QUO:%.*]]) { | ||
; CHECK-NEXT: [[ENTRY:.*:]] | ||
; CHECK-NEXT: store i32 -2, ptr [[QUO]], align 4 | ||
; CHECK-NEXT: ret float 1.000000e+00 | ||
; | ||
entry: | ||
%call = call float @remquof(float -5.000000e+00, float 3.000000e+00, ptr %quo) | ||
ret float %call | ||
} | ||
|
||
define float @remquo_f32_quo_sign(ptr %quo) { | ||
; CHECK-LABEL: define float @remquo_f32_quo_sign( | ||
; CHECK-SAME: ptr [[QUO:%.*]]) { | ||
; CHECK-NEXT: [[ENTRY:.*:]] | ||
; CHECK-NEXT: store i32 2, ptr [[QUO]], align 4 | ||
; CHECK-NEXT: ret float -1.000000e+00 | ||
; | ||
entry: | ||
%call = call float @remquof(float 5.000000e+00, float 3.000000e+00, ptr %quo) | ||
ret float %call | ||
} | ||
|
||
define float @remquo_f32_round(ptr %quo) { | ||
; CHECK-LABEL: define float @remquo_f32_round( | ||
; CHECK-SAME: ptr [[QUO:%.*]]) { | ||
; CHECK-NEXT: [[ENTRY:.*:]] | ||
; CHECK-NEXT: store i32 -6, ptr [[QUO]], align 4 | ||
; CHECK-NEXT: ret float 0xBFC9999900000000 | ||
; | ||
entry: | ||
%call = call float @remquof(float -5.000000e+00, float 0x3FE99999A0000000, ptr %quo) | ||
ret float %call | ||
} | ||
|
||
define double @remquo_f64(ptr %quo) { | ||
; CHECK-LABEL: define double @remquo_f64( | ||
; CHECK-SAME: ptr [[QUO:%.*]]) { | ||
; CHECK-NEXT: [[ENTRY:.*:]] | ||
; CHECK-NEXT: store i32 -5, ptr [[QUO]], align 4 | ||
; CHECK-NEXT: ret double -0.000000e+00 | ||
; | ||
entry: | ||
%call = call double @remquo(double -5.000000e+00, double 1.000000e+00, ptr %quo) | ||
ret double %call | ||
} | ||
|
||
; Negative tests | ||
|
||
define float @remquo_f32_inf_x(ptr %quo) { | ||
; CHECK-LABEL: define float @remquo_f32_inf_x( | ||
; CHECK-SAME: ptr [[QUO:%.*]]) { | ||
; CHECK-NEXT: [[ENTRY:.*:]] | ||
; CHECK-NEXT: [[CALL:%.*]] = call float @remquof(float 0x7FF0000000000000, float 1.000000e+00, ptr [[QUO]]) | ||
; CHECK-NEXT: ret float [[CALL]] | ||
; | ||
entry: | ||
%call = call float @remquof(float 0x7FF0000000000000, float 1.000000e+00, ptr %quo) | ||
ret float %call | ||
} | ||
|
||
define float @remquo_f32_zero_y(ptr %quo) { | ||
; CHECK-LABEL: define float @remquo_f32_zero_y( | ||
; CHECK-SAME: ptr [[QUO:%.*]]) { | ||
; CHECK-NEXT: [[ENTRY:.*:]] | ||
; CHECK-NEXT: [[CALL:%.*]] = call float @remquof(float -5.000000e+00, float 0.000000e+00, ptr [[QUO]]) | ||
; CHECK-NEXT: ret float [[CALL]] | ||
; | ||
entry: | ||
%call = call float @remquof(float -5.000000e+00, float 0.000000e+00, ptr %quo) | ||
dtcxzyw marked this conversation as resolved.
Show resolved
Hide resolved
|
||
ret float %call | ||
} | ||
|
||
define float @remquo_f32_nzero_y(ptr %quo) { | ||
; CHECK-LABEL: define float @remquo_f32_nzero_y( | ||
; CHECK-SAME: ptr [[QUO:%.*]]) { | ||
; CHECK-NEXT: [[ENTRY:.*:]] | ||
; CHECK-NEXT: [[CALL:%.*]] = call float @remquof(float -5.000000e+00, float -0.000000e+00, ptr [[QUO]]) | ||
; CHECK-NEXT: ret float [[CALL]] | ||
; | ||
entry: | ||
%call = call float @remquof(float -5.000000e+00, float -0.000000e+00, ptr %quo) | ||
ret float %call | ||
} | ||
|
||
define float @remquo_f32_nan_x(ptr %quo) { | ||
; CHECK-LABEL: define float @remquo_f32_nan_x( | ||
; CHECK-SAME: ptr [[QUO:%.*]]) { | ||
; CHECK-NEXT: [[ENTRY:.*:]] | ||
; CHECK-NEXT: [[CALL:%.*]] = call float @remquof(float 0x7FF8000000000000, float 1.000000e+00, ptr [[QUO]]) | ||
; CHECK-NEXT: ret float [[CALL]] | ||
; | ||
entry: | ||
%call = call float @remquof(float 0x7FF8000000000000, float 1.000000e+00, ptr %quo) | ||
ret float %call | ||
} | ||
|
||
define float @remquo_f32_nan_y(ptr %quo) { | ||
; CHECK-LABEL: define float @remquo_f32_nan_y( | ||
; CHECK-SAME: ptr [[QUO:%.*]]) { | ||
; CHECK-NEXT: [[ENTRY:.*:]] | ||
; CHECK-NEXT: [[CALL:%.*]] = call float @remquof(float 1.000000e+00, float 0x7FF8000000000000, ptr [[QUO]]) | ||
; CHECK-NEXT: ret float [[CALL]] | ||
; | ||
entry: | ||
%call = call float @remquof(float 1.000000e+00, float 0x7FF8000000000000, ptr %quo) | ||
ret float %call | ||
} | ||
|
||
dtcxzyw marked this conversation as resolved.
Show resolved
Hide resolved
|
||
define float @remquo_f32_strictfp(ptr %quo) strictfp { | ||
; CHECK-LABEL: define float @remquo_f32_strictfp( | ||
; CHECK-SAME: ptr [[QUO:%.*]]) #[[ATTR0:[0-9]+]] { | ||
; CHECK-NEXT: [[ENTRY:.*:]] | ||
; CHECK-NEXT: [[CALL:%.*]] = call float @remquof(float -5.000000e+00, float 3.000000e+00, ptr [[QUO]]) #[[ATTR0]] | ||
; CHECK-NEXT: ret float [[CALL]] | ||
; | ||
entry: | ||
%call = call float @remquof(float -5.000000e+00, float 3.000000e+00, ptr %quo) strictfp | ||
ret float %call | ||
} | ||
|
||
define float @remquo_f32_zero_y_strictfp(ptr %quo) strictfp { | ||
; CHECK-LABEL: define float @remquo_f32_zero_y_strictfp( | ||
; CHECK-SAME: ptr [[QUO:%.*]]) #[[ATTR0]] { | ||
; CHECK-NEXT: [[ENTRY:.*:]] | ||
; CHECK-NEXT: [[CALL:%.*]] = call float @remquof(float -5.000000e+00, float 0.000000e+00, ptr [[QUO]]) #[[ATTR0]] | ||
; CHECK-NEXT: ret float [[CALL]] | ||
; | ||
entry: | ||
%call = call float @remquof(float -5.000000e+00, float 0.000000e+00, ptr %quo) strictfp | ||
ret float %call | ||
} | ||
|
||
declare float @remquof(float, float, ptr) | ||
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. Need a non-edgcase strictfp case? 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. See |
||
declare double @remquo(double, double, ptr) |
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,16 @@ | ||
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 5 | ||
; RUN: opt < %s -passes=instcombine -S | FileCheck %s | ||
|
||
define fp128 @remquo_fp128(ptr %quo) { | ||
; CHECK-LABEL: define fp128 @remquo_fp128( | ||
; CHECK-SAME: ptr [[QUO:%.*]]) { | ||
; CHECK-NEXT: [[ENTRY:.*:]] | ||
; CHECK-NEXT: store i32 -2, ptr [[QUO]], align 4 | ||
; CHECK-NEXT: ret fp128 0xL00000000000000003FFF000000000000 | ||
; | ||
entry: | ||
%call = call fp128 @remquol(fp128 0xL0000000000000000C001400000000000, fp128 0xL00000000000000004000800000000000, ptr %quo) | ||
ret fp128 %call | ||
} | ||
|
||
declare fp128 @remquol(fp128, fp128, ptr) |
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,16 @@ | ||
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 5 | ||
; RUN: opt < %s -passes=instcombine -S | FileCheck %s | ||
|
||
define x86_fp80 @remquo_fp80(ptr %quo) { | ||
; CHECK-LABEL: define x86_fp80 @remquo_fp80( | ||
; CHECK-SAME: ptr [[QUO:%.*]]) { | ||
; CHECK-NEXT: [[ENTRY:.*:]] | ||
; CHECK-NEXT: store i32 -2, ptr [[QUO]], align 4 | ||
; CHECK-NEXT: ret x86_fp80 0xK3FFF8000000000000000 | ||
; | ||
entry: | ||
%call = call x86_fp80 @remquol(x86_fp80 0xKC001A000000000000000, x86_fp80 0xK4000C000000000000000, ptr %quo) | ||
ret x86_fp80 %call | ||
} | ||
|
||
declare x86_fp80 @remquol(x86_fp80, x86_fp80, ptr) |
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,16 @@ | ||
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 5 | ||
; RUN: opt < %s -passes=instcombine -S | FileCheck %s | ||
|
||
define ppc_fp128 @remquo_ppc_fp128(ptr %quo) { | ||
; CHECK-LABEL: define ppc_fp128 @remquo_ppc_fp128( | ||
; CHECK-SAME: ptr [[QUO:%.*]]) { | ||
; CHECK-NEXT: [[ENTRY:.*:]] | ||
; CHECK-NEXT: store i32 -2, ptr [[QUO]], align 4 | ||
; CHECK-NEXT: ret ppc_fp128 0xM3FF00000000000000000000000000000 | ||
; | ||
entry: | ||
%call = call ppc_fp128 @remquol(ppc_fp128 0xMC0140000000000000000000000000000, ppc_fp128 0xM40080000000000000000000000000000, ptr %quo) | ||
ret ppc_fp128 %call | ||
} | ||
|
||
declare ppc_fp128 @remquol(ppc_fp128, ppc_fp128, ptr) |
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.
The current implementation is slightly conservative. The integer part of
x/y
may be out of range of i32.