-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[SimplifyLibCalls] Constant fold nan libcall #101459
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
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
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,80 @@ | ||
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 5 | ||
; RUN: opt < %s -passes=instcombine -S | FileCheck %s | ||
|
||
@empty = private unnamed_addr constant [1 x i8] zeroinitializer, align 1 | ||
@dec = private unnamed_addr constant [2 x i8] c"1\00", align 1 | ||
@hex = private unnamed_addr constant [4 x i8] c"0xf\00", align 1 | ||
|
||
define double @nan_empty() { | ||
; CHECK-LABEL: define double @nan_empty() { | ||
; CHECK-NEXT: ret double 0x7FF8000000000000 | ||
; | ||
%res = call double @nan(ptr @empty) | ||
ret double %res | ||
} | ||
|
||
define double @nan_dec() { | ||
; CHECK-LABEL: define double @nan_dec() { | ||
; CHECK-NEXT: ret double 0x7FF8000000000001 | ||
; | ||
%res = call double @nan(ptr @dec) | ||
ret double %res | ||
} | ||
|
||
define double @nan_hex() { | ||
; CHECK-LABEL: define double @nan_hex() { | ||
; CHECK-NEXT: ret double 0x7FF800000000000F | ||
; | ||
%res = call double @nan(ptr @hex) | ||
ret double %res | ||
} | ||
|
||
define float @nanf_empty() { | ||
; CHECK-LABEL: define float @nanf_empty() { | ||
; CHECK-NEXT: ret float 0x7FF8000000000000 | ||
; | ||
%res = call float @nanf(ptr @empty) | ||
ret float %res | ||
} | ||
|
||
; nagative tests | ||
|
||
define double @nan_poison() { | ||
; CHECK-LABEL: define double @nan_poison() { | ||
; CHECK-NEXT: [[RES:%.*]] = call double @nan(ptr poison) | ||
; CHECK-NEXT: ret double [[RES]] | ||
; | ||
%res = call double @nan(ptr poison) | ||
ret double %res | ||
} | ||
|
||
define double @nan_undef() { | ||
; CHECK-LABEL: define double @nan_undef() { | ||
; CHECK-NEXT: [[RES:%.*]] = call double @nan(ptr undef) | ||
; CHECK-NEXT: ret double [[RES]] | ||
; | ||
%res = call double @nan(ptr undef) | ||
ret double %res | ||
} | ||
|
||
define double @nan_null() { | ||
; CHECK-LABEL: define double @nan_null() { | ||
; CHECK-NEXT: [[RES:%.*]] = call double @nan(ptr null) | ||
; CHECK-NEXT: ret double [[RES]] | ||
; | ||
%res = call double @nan(ptr null) | ||
ret double %res | ||
} | ||
|
||
dtcxzyw marked this conversation as resolved.
Show resolved
Hide resolved
|
||
define double @nan_non_constant(ptr %x) { | ||
; CHECK-LABEL: define double @nan_non_constant( | ||
; CHECK-SAME: ptr [[X:%.*]]) { | ||
; CHECK-NEXT: [[RES:%.*]] = call double @nan(ptr [[X]]) | ||
; CHECK-NEXT: ret double [[RES]] | ||
; | ||
%res = call double @nan(ptr %x) | ||
ret double %res | ||
} | ||
|
||
declare float @nanf(ptr) | ||
declare double @nan(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,32 @@ | ||
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 5 | ||
; RUN: opt < %s -passes=instcombine -S | FileCheck %s | ||
|
||
@empty = private unnamed_addr constant [1 x i8] zeroinitializer, align 1 | ||
@dec = private unnamed_addr constant [2 x i8] c"1\00", align 1 | ||
@hex = private unnamed_addr constant [4 x i8] c"0xf\00", align 1 | ||
|
||
define fp128 @nanl_empty() { | ||
; CHECK-LABEL: define fp128 @nanl_empty() { | ||
; CHECK-NEXT: ret fp128 0xL00000000000000007FFF800000000000 | ||
; | ||
%res = call fp128 @nanl(ptr @empty) | ||
ret fp128 %res | ||
} | ||
|
||
define fp128 @nanl_dec() { | ||
; CHECK-LABEL: define fp128 @nanl_dec() { | ||
; CHECK-NEXT: ret fp128 0xL00000000000000017FFF800000000000 | ||
; | ||
%res = call fp128 @nanl(ptr @dec) | ||
ret fp128 %res | ||
} | ||
|
||
define fp128 @nanl_hex() { | ||
; CHECK-LABEL: define fp128 @nanl_hex() { | ||
; CHECK-NEXT: ret fp128 0xL000000000000000F7FFF800000000000 | ||
; | ||
%res = call fp128 @nanl(ptr @hex) | ||
ret fp128 %res | ||
} | ||
|
||
declare fp128 @nanl(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,32 @@ | ||
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 5 | ||
; RUN: opt < %s -passes=instcombine -S | FileCheck %s | ||
|
||
@empty = private unnamed_addr constant [1 x i8] zeroinitializer, align 1 | ||
@dec = private unnamed_addr constant [2 x i8] c"1\00", align 1 | ||
@hex = private unnamed_addr constant [4 x i8] c"0xf\00", align 1 | ||
|
||
define x86_fp80 @nanl_empty() { | ||
; CHECK-LABEL: define x86_fp80 @nanl_empty() { | ||
; CHECK-NEXT: ret x86_fp80 0xK7FFFC000000000000000 | ||
; | ||
%res = call x86_fp80 @nanl(ptr @empty) | ||
ret x86_fp80 %res | ||
} | ||
|
||
define x86_fp80 @nanl_dec() { | ||
; CHECK-LABEL: define x86_fp80 @nanl_dec() { | ||
; CHECK-NEXT: ret x86_fp80 0xK7FFFC000000000000001 | ||
; | ||
%res = call x86_fp80 @nanl(ptr @dec) | ||
ret x86_fp80 %res | ||
} | ||
|
||
define x86_fp80 @nanl_hex() { | ||
; CHECK-LABEL: define x86_fp80 @nanl_hex() { | ||
; CHECK-NEXT: ret x86_fp80 0xK7FFFC00000000000000F | ||
; | ||
%res = call x86_fp80 @nanl(ptr @hex) | ||
ret x86_fp80 %res | ||
} | ||
|
||
declare x86_fp80 @nanl(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,32 @@ | ||
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 5 | ||
; RUN: opt < %s -passes=instcombine -S | FileCheck %s | ||
|
||
@empty = private unnamed_addr constant [1 x i8] zeroinitializer, align 1 | ||
@dec = private unnamed_addr constant [2 x i8] c"1\00", align 1 | ||
@hex = private unnamed_addr constant [4 x i8] c"0xf\00", align 1 | ||
|
||
define ppc_fp128 @nanl_empty() { | ||
; CHECK-LABEL: define ppc_fp128 @nanl_empty() { | ||
; CHECK-NEXT: ret ppc_fp128 0xM7FF80000000000000000000000000000 | ||
; | ||
%res = call ppc_fp128 @nanl(ptr @empty) | ||
ret ppc_fp128 %res | ||
} | ||
|
||
define ppc_fp128 @nanl_dec() { | ||
; CHECK-LABEL: define ppc_fp128 @nanl_dec() { | ||
; CHECK-NEXT: ret ppc_fp128 0xM7FF80000000000010000000000000000 | ||
; | ||
%res = call ppc_fp128 @nanl(ptr @dec) | ||
ret ppc_fp128 %res | ||
} | ||
|
||
define ppc_fp128 @nanl_hex() { | ||
; CHECK-LABEL: define ppc_fp128 @nanl_hex() { | ||
; CHECK-NEXT: ret ppc_fp128 0xM7FF800000000000F0000000000000000 | ||
; | ||
%res = call ppc_fp128 @nanl(ptr @hex) | ||
ret ppc_fp128 %res | ||
} | ||
|
||
declare ppc_fp128 @nanl(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.
Uh oh!
There was an error while loading. Please reload this page.