-
Notifications
You must be signed in to change notification settings - Fork 13.5k
[SelectionDAG] Preserve fast math flags when legalizing/promoting #130124
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
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
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,90 @@ | ||
; NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py UTC_ARGS: --version 5 | ||
; RUN: llc < %s -mtriple=aarch64 -mattr=-fullfp16 -stop-after=finalize-isel | FileCheck %s --check-prefixes=CHECK-CVT | ||
; RUN: llc < %s -mtriple=aarch64 -mattr=+fullfp16 -stop-after=finalize-isel | FileCheck %s --check-prefixes=CHECK-FP16 | ||
|
||
; Check that the output instructions have the same fast math flags as the input | ||
; fadd, even when fadd is promoted to float type. | ||
|
||
define half @normal_fadd(half %x, half %y) { | ||
; CHECK-CVT-LABEL: name: normal_fadd | ||
; CHECK-CVT: bb.0.entry: | ||
; CHECK-CVT-NEXT: liveins: $h0, $h1 | ||
; CHECK-CVT-NEXT: {{ $}} | ||
; CHECK-CVT-NEXT: [[COPY:%[0-9]+]]:fpr16 = COPY $h1 | ||
; CHECK-CVT-NEXT: [[COPY1:%[0-9]+]]:fpr16 = COPY $h0 | ||
; CHECK-CVT-NEXT: [[FCVTSHr:%[0-9]+]]:fpr32 = nofpexcept FCVTSHr [[COPY]], implicit $fpcr | ||
; CHECK-CVT-NEXT: [[FCVTSHr1:%[0-9]+]]:fpr32 = nofpexcept FCVTSHr [[COPY1]], implicit $fpcr | ||
; CHECK-CVT-NEXT: [[FADDSrr:%[0-9]+]]:fpr32 = nofpexcept FADDSrr killed [[FCVTSHr1]], killed [[FCVTSHr]], implicit $fpcr | ||
; CHECK-CVT-NEXT: [[FCVTHSr:%[0-9]+]]:fpr16 = nofpexcept FCVTHSr killed [[FADDSrr]], implicit $fpcr | ||
; CHECK-CVT-NEXT: $h0 = COPY [[FCVTHSr]] | ||
; CHECK-CVT-NEXT: RET_ReallyLR implicit $h0 | ||
; | ||
; CHECK-FP16-LABEL: name: normal_fadd | ||
; CHECK-FP16: bb.0.entry: | ||
; CHECK-FP16-NEXT: liveins: $h0, $h1 | ||
; CHECK-FP16-NEXT: {{ $}} | ||
; CHECK-FP16-NEXT: [[COPY:%[0-9]+]]:fpr16 = COPY $h1 | ||
; CHECK-FP16-NEXT: [[COPY1:%[0-9]+]]:fpr16 = COPY $h0 | ||
; CHECK-FP16-NEXT: [[FADDHrr:%[0-9]+]]:fpr16 = nofpexcept FADDHrr [[COPY1]], [[COPY]], implicit $fpcr | ||
; CHECK-FP16-NEXT: $h0 = COPY [[FADDHrr]] | ||
; CHECK-FP16-NEXT: RET_ReallyLR implicit $h0 | ||
entry: | ||
%add = fadd half %x, %y | ||
ret half %add | ||
} | ||
|
||
define half @fast_fadd(half %x, half %y) { | ||
; CHECK-CVT-LABEL: name: fast_fadd | ||
; CHECK-CVT: bb.0.entry: | ||
; CHECK-CVT-NEXT: liveins: $h0, $h1 | ||
; CHECK-CVT-NEXT: {{ $}} | ||
; CHECK-CVT-NEXT: [[COPY:%[0-9]+]]:fpr16 = COPY $h1 | ||
; CHECK-CVT-NEXT: [[COPY1:%[0-9]+]]:fpr16 = COPY $h0 | ||
; CHECK-CVT-NEXT: [[FCVTSHr:%[0-9]+]]:fpr32 = nnan ninf nsz arcp contract afn reassoc nofpexcept FCVTSHr [[COPY]], implicit $fpcr | ||
; CHECK-CVT-NEXT: [[FCVTSHr1:%[0-9]+]]:fpr32 = nnan ninf nsz arcp contract afn reassoc nofpexcept FCVTSHr [[COPY1]], implicit $fpcr | ||
; CHECK-CVT-NEXT: [[FADDSrr:%[0-9]+]]:fpr32 = nnan ninf nsz arcp contract afn reassoc nofpexcept FADDSrr killed [[FCVTSHr1]], killed [[FCVTSHr]], implicit $fpcr | ||
; CHECK-CVT-NEXT: [[FCVTHSr:%[0-9]+]]:fpr16 = nnan ninf nsz arcp contract afn reassoc nofpexcept FCVTHSr killed [[FADDSrr]], implicit $fpcr | ||
; CHECK-CVT-NEXT: $h0 = COPY [[FCVTHSr]] | ||
; CHECK-CVT-NEXT: RET_ReallyLR implicit $h0 | ||
; | ||
; CHECK-FP16-LABEL: name: fast_fadd | ||
; CHECK-FP16: bb.0.entry: | ||
; CHECK-FP16-NEXT: liveins: $h0, $h1 | ||
; CHECK-FP16-NEXT: {{ $}} | ||
; CHECK-FP16-NEXT: [[COPY:%[0-9]+]]:fpr16 = COPY $h1 | ||
; CHECK-FP16-NEXT: [[COPY1:%[0-9]+]]:fpr16 = COPY $h0 | ||
; CHECK-FP16-NEXT: [[FADDHrr:%[0-9]+]]:fpr16 = nnan ninf nsz arcp contract afn reassoc nofpexcept FADDHrr [[COPY1]], [[COPY]], implicit $fpcr | ||
; CHECK-FP16-NEXT: $h0 = COPY [[FADDHrr]] | ||
; CHECK-FP16-NEXT: RET_ReallyLR implicit $h0 | ||
entry: | ||
%add = fadd fast half %x, %y | ||
ret half %add | ||
} | ||
|
||
define half @ninf_fadd(half %x, half %y) { | ||
; CHECK-CVT-LABEL: name: ninf_fadd | ||
; CHECK-CVT: bb.0.entry: | ||
; CHECK-CVT-NEXT: liveins: $h0, $h1 | ||
; CHECK-CVT-NEXT: {{ $}} | ||
; CHECK-CVT-NEXT: [[COPY:%[0-9]+]]:fpr16 = COPY $h1 | ||
; CHECK-CVT-NEXT: [[COPY1:%[0-9]+]]:fpr16 = COPY $h0 | ||
; CHECK-CVT-NEXT: [[FCVTSHr:%[0-9]+]]:fpr32 = ninf nofpexcept FCVTSHr [[COPY]], implicit $fpcr | ||
; CHECK-CVT-NEXT: [[FCVTSHr1:%[0-9]+]]:fpr32 = ninf nofpexcept FCVTSHr [[COPY1]], implicit $fpcr | ||
; CHECK-CVT-NEXT: [[FADDSrr:%[0-9]+]]:fpr32 = ninf nofpexcept FADDSrr killed [[FCVTSHr1]], killed [[FCVTSHr]], implicit $fpcr | ||
; CHECK-CVT-NEXT: [[FCVTHSr:%[0-9]+]]:fpr16 = ninf nofpexcept FCVTHSr killed [[FADDSrr]], implicit $fpcr | ||
; CHECK-CVT-NEXT: $h0 = COPY [[FCVTHSr]] | ||
; CHECK-CVT-NEXT: RET_ReallyLR implicit $h0 | ||
; | ||
; CHECK-FP16-LABEL: name: ninf_fadd | ||
; CHECK-FP16: bb.0.entry: | ||
; CHECK-FP16-NEXT: liveins: $h0, $h1 | ||
; CHECK-FP16-NEXT: {{ $}} | ||
; CHECK-FP16-NEXT: [[COPY:%[0-9]+]]:fpr16 = COPY $h1 | ||
; CHECK-FP16-NEXT: [[COPY1:%[0-9]+]]:fpr16 = COPY $h0 | ||
; CHECK-FP16-NEXT: [[FADDHrr:%[0-9]+]]:fpr16 = ninf nofpexcept FADDHrr [[COPY1]], [[COPY]], implicit $fpcr | ||
; CHECK-FP16-NEXT: $h0 = COPY [[FADDHrr]] | ||
; CHECK-FP16-NEXT: RET_ReallyLR implicit $h0 | ||
entry: | ||
%add = fadd ninf half %x, %y | ||
ret half %add | ||
} |
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,112 @@ | ||
; NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py UTC_ARGS: --version 5 | ||
; RUN: llc < %s -mtriple=arm -mattr=+vfp4d16sp,-fullfp16 -stop-after=finalize-isel | FileCheck %s --check-prefixes=CHECK-CVT | ||
; RUN: llc < %s -mtriple=arm -mattr=+vfp4d16sp,+fullfp16 -stop-after=finalize-isel | FileCheck %s --check-prefixes=CHECK-FP16 | ||
|
||
; Check that the output instructions have the same fast math flags as the input | ||
; fadd, even when f16 is legalized to f32. | ||
; FIXME: We don't get fast math flags on VCVTBHS because they get lost during a | ||
; DAGCombine transformation. | ||
; FIXME: We don't get fast math flags on VCVTBSH because the outermost node in | ||
; the isel pattern is COPY_TO_REGCLASS and the fast math flags end up there. | ||
|
||
define half @normal_fadd(half %x, half %y) { | ||
; CHECK-CVT-LABEL: name: normal_fadd | ||
; CHECK-CVT: bb.0.entry: | ||
; CHECK-CVT-NEXT: liveins: $r0, $r1 | ||
; CHECK-CVT-NEXT: {{ $}} | ||
; CHECK-CVT-NEXT: [[COPY:%[0-9]+]]:gpr = COPY $r1 | ||
; CHECK-CVT-NEXT: [[COPY1:%[0-9]+]]:gpr = COPY $r0 | ||
; CHECK-CVT-NEXT: [[COPY2:%[0-9]+]]:spr = COPY [[COPY1]] | ||
; CHECK-CVT-NEXT: [[COPY3:%[0-9]+]]:spr = COPY [[COPY]] | ||
; CHECK-CVT-NEXT: [[VCVTBHS:%[0-9]+]]:spr = VCVTBHS killed [[COPY3]], 14 /* CC::al */, $noreg | ||
; CHECK-CVT-NEXT: [[VCVTBHS1:%[0-9]+]]:spr = VCVTBHS killed [[COPY2]], 14 /* CC::al */, $noreg | ||
; CHECK-CVT-NEXT: [[VADDS:%[0-9]+]]:spr = VADDS killed [[VCVTBHS1]], killed [[VCVTBHS]], 14 /* CC::al */, $noreg | ||
; CHECK-CVT-NEXT: [[DEF:%[0-9]+]]:spr = IMPLICIT_DEF | ||
; CHECK-CVT-NEXT: [[VCVTBSH:%[0-9]+]]:spr = VCVTBSH [[DEF]], killed [[VADDS]], 14 /* CC::al */, $noreg | ||
; CHECK-CVT-NEXT: [[COPY4:%[0-9]+]]:gpr = COPY [[VCVTBSH]] | ||
; CHECK-CVT-NEXT: $r0 = COPY [[COPY4]] | ||
; CHECK-CVT-NEXT: MOVPCLR 14 /* CC::al */, $noreg, implicit $r0 | ||
; | ||
; CHECK-FP16-LABEL: name: normal_fadd | ||
; CHECK-FP16: bb.0.entry: | ||
; CHECK-FP16-NEXT: liveins: $r0, $r1 | ||
; CHECK-FP16-NEXT: {{ $}} | ||
; CHECK-FP16-NEXT: [[COPY:%[0-9]+]]:rgpr = COPY $r1 | ||
; CHECK-FP16-NEXT: [[COPY1:%[0-9]+]]:rgpr = COPY $r0 | ||
; CHECK-FP16-NEXT: [[VMOVHR:%[0-9]+]]:hpr = VMOVHR [[COPY]], 14, $noreg | ||
; CHECK-FP16-NEXT: [[VMOVHR1:%[0-9]+]]:hpr = VMOVHR [[COPY1]], 14, $noreg | ||
; CHECK-FP16-NEXT: [[VADDH:%[0-9]+]]:hpr = VADDH killed [[VMOVHR1]], killed [[VMOVHR]], 14, $noreg | ||
; CHECK-FP16-NEXT: $r0 = COPY [[VADDH]] | ||
; CHECK-FP16-NEXT: MOVPCLR 14 /* CC::al */, $noreg, implicit $r0 | ||
entry: | ||
%add = fadd half %x, %y | ||
ret half %add | ||
} | ||
|
||
define half @fast_fadd(half %x, half %y) { | ||
; CHECK-CVT-LABEL: name: fast_fadd | ||
; CHECK-CVT: bb.0.entry: | ||
; CHECK-CVT-NEXT: liveins: $r0, $r1 | ||
; CHECK-CVT-NEXT: {{ $}} | ||
; CHECK-CVT-NEXT: [[COPY:%[0-9]+]]:gpr = COPY $r1 | ||
; CHECK-CVT-NEXT: [[COPY1:%[0-9]+]]:gpr = COPY $r0 | ||
; CHECK-CVT-NEXT: [[COPY2:%[0-9]+]]:spr = COPY [[COPY1]] | ||
; CHECK-CVT-NEXT: [[COPY3:%[0-9]+]]:spr = COPY [[COPY]] | ||
; CHECK-CVT-NEXT: [[VCVTBHS:%[0-9]+]]:spr = VCVTBHS killed [[COPY3]], 14 /* CC::al */, $noreg | ||
; CHECK-CVT-NEXT: [[VCVTBHS1:%[0-9]+]]:spr = VCVTBHS killed [[COPY2]], 14 /* CC::al */, $noreg | ||
; CHECK-CVT-NEXT: [[VADDS:%[0-9]+]]:spr = nnan ninf nsz arcp contract afn reassoc VADDS killed [[VCVTBHS1]], killed [[VCVTBHS]], 14 /* CC::al */, $noreg | ||
; CHECK-CVT-NEXT: [[DEF:%[0-9]+]]:spr = IMPLICIT_DEF | ||
; CHECK-CVT-NEXT: [[VCVTBSH:%[0-9]+]]:spr = VCVTBSH [[DEF]], killed [[VADDS]], 14 /* CC::al */, $noreg | ||
; CHECK-CVT-NEXT: [[COPY4:%[0-9]+]]:gpr = COPY [[VCVTBSH]] | ||
; CHECK-CVT-NEXT: $r0 = COPY [[COPY4]] | ||
; CHECK-CVT-NEXT: MOVPCLR 14 /* CC::al */, $noreg, implicit $r0 | ||
; | ||
; CHECK-FP16-LABEL: name: fast_fadd | ||
; CHECK-FP16: bb.0.entry: | ||
; CHECK-FP16-NEXT: liveins: $r0, $r1 | ||
; CHECK-FP16-NEXT: {{ $}} | ||
; CHECK-FP16-NEXT: [[COPY:%[0-9]+]]:rgpr = COPY $r1 | ||
; CHECK-FP16-NEXT: [[COPY1:%[0-9]+]]:rgpr = COPY $r0 | ||
; CHECK-FP16-NEXT: [[VMOVHR:%[0-9]+]]:hpr = VMOVHR [[COPY]], 14, $noreg | ||
; CHECK-FP16-NEXT: [[VMOVHR1:%[0-9]+]]:hpr = VMOVHR [[COPY1]], 14, $noreg | ||
; CHECK-FP16-NEXT: [[VADDH:%[0-9]+]]:hpr = nnan ninf nsz arcp contract afn reassoc VADDH killed [[VMOVHR1]], killed [[VMOVHR]], 14, $noreg | ||
; CHECK-FP16-NEXT: $r0 = COPY [[VADDH]] | ||
; CHECK-FP16-NEXT: MOVPCLR 14 /* CC::al */, $noreg, implicit $r0 | ||
entry: | ||
%add = fadd fast half %x, %y | ||
ret half %add | ||
} | ||
|
||
define half @ninf_fadd(half %x, half %y) { | ||
; CHECK-CVT-LABEL: name: ninf_fadd | ||
; CHECK-CVT: bb.0.entry: | ||
; CHECK-CVT-NEXT: liveins: $r0, $r1 | ||
; CHECK-CVT-NEXT: {{ $}} | ||
; CHECK-CVT-NEXT: [[COPY:%[0-9]+]]:gpr = COPY $r1 | ||
; CHECK-CVT-NEXT: [[COPY1:%[0-9]+]]:gpr = COPY $r0 | ||
; CHECK-CVT-NEXT: [[COPY2:%[0-9]+]]:spr = COPY [[COPY1]] | ||
; CHECK-CVT-NEXT: [[COPY3:%[0-9]+]]:spr = COPY [[COPY]] | ||
; CHECK-CVT-NEXT: [[VCVTBHS:%[0-9]+]]:spr = VCVTBHS killed [[COPY3]], 14 /* CC::al */, $noreg | ||
; CHECK-CVT-NEXT: [[VCVTBHS1:%[0-9]+]]:spr = VCVTBHS killed [[COPY2]], 14 /* CC::al */, $noreg | ||
; CHECK-CVT-NEXT: [[VADDS:%[0-9]+]]:spr = ninf VADDS killed [[VCVTBHS1]], killed [[VCVTBHS]], 14 /* CC::al */, $noreg | ||
; CHECK-CVT-NEXT: [[DEF:%[0-9]+]]:spr = IMPLICIT_DEF | ||
; CHECK-CVT-NEXT: [[VCVTBSH:%[0-9]+]]:spr = VCVTBSH [[DEF]], killed [[VADDS]], 14 /* CC::al */, $noreg | ||
; CHECK-CVT-NEXT: [[COPY4:%[0-9]+]]:gpr = COPY [[VCVTBSH]] | ||
; CHECK-CVT-NEXT: $r0 = COPY [[COPY4]] | ||
; CHECK-CVT-NEXT: MOVPCLR 14 /* CC::al */, $noreg, implicit $r0 | ||
; | ||
; CHECK-FP16-LABEL: name: ninf_fadd | ||
; CHECK-FP16: bb.0.entry: | ||
; CHECK-FP16-NEXT: liveins: $r0, $r1 | ||
; CHECK-FP16-NEXT: {{ $}} | ||
; CHECK-FP16-NEXT: [[COPY:%[0-9]+]]:rgpr = COPY $r1 | ||
; CHECK-FP16-NEXT: [[COPY1:%[0-9]+]]:rgpr = COPY $r0 | ||
; CHECK-FP16-NEXT: [[VMOVHR:%[0-9]+]]:hpr = VMOVHR [[COPY]], 14, $noreg | ||
; CHECK-FP16-NEXT: [[VMOVHR1:%[0-9]+]]:hpr = VMOVHR [[COPY1]], 14, $noreg | ||
; CHECK-FP16-NEXT: [[VADDH:%[0-9]+]]:hpr = ninf VADDH killed [[VMOVHR1]], killed [[VMOVHR]], 14, $noreg | ||
; CHECK-FP16-NEXT: $r0 = COPY [[VADDH]] | ||
; CHECK-FP16-NEXT: MOVPCLR 14 /* CC::al */, $noreg, implicit $r0 | ||
entry: | ||
%add = fadd ninf half %x, %y | ||
ret half %add | ||
} |
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
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.
No need to do this for the standard fp ops below as the flags get already propagated, right?
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.
I'm not seeing where that happens below, but presumably, if that happens below somewhere, that is now no longer needed with this addition and could be cleaned up there, rather than here?
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.
I'll clean up the now-redundant setting of flags later in this function in a follow-on patch.