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

[TwoAddressInstruction] Use isPlainlyKilled in processTiedPairs #65976

Merged
merged 1 commit into from
Sep 19, 2023
Merged

[TwoAddressInstruction] Use isPlainlyKilled in processTiedPairs #65976

merged 1 commit into from
Sep 19, 2023

Conversation

jayfoad
Copy link
Contributor

@jayfoad jayfoad commented Sep 11, 2023

Calling isPlainlyKilled instead of directly checking for a kill flag
should make processTiedPairs behave the same with LiveIntervals
(i.e. when compiling with -early-live-intervals) as it does with
LiveVariables.

@jayfoad jayfoad requested a review from a team as a code owner September 11, 2023 16:20
; CHECK-LIS-NEXT: pshufd {{.*#+}} xmm0 = xmm3[1,0,1,1]
; CHECK-LIS-NEXT: pblendw {{.*#+}} xmm2 = xmm1[0,1],xmm2[2,3,4,5,6,7]
; CHECK-LIS-NEXT: por %xmm0, %xmm2
; CHECK-LIS-NEXT: movdqa %xmm2, %xmm0
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Regression here but I don't think TwoAddressInstruction is doing anything wrong. I can see RegisterCoalescer rematerializing a V_SET0 in a slightly unfortunate place which causes overlapping lifetimes for (a) one value that wants to use $xmm0 on input and (b) another value that wants to use $xmm0 on return, so one of them has to pick a different register and that causes the extra COPY.

Copy link
Collaborator

Choose a reason for hiding this comment

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

We have similar issues with multiple zero vector registers, so normally I'd say this is acceptable but I'm worried this change might be encouraging the underlying problem?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I saw equal and opposite changes of this sort in combine-or.ll and combine-rotates.ll so I suspect it is neither better nor worse, but I'm not sure how to prove that.

Copy link
Collaborator

@RKSimon RKSimon left a comment

Choose a reason for hiding this comment

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

Please can you update the patch title/description?

@@ -2,7 +2,8 @@
; Test removal of AND operations that don't affect last 6 bits of rotate amount
; operand.
;
; RUN: llc < %s -mtriple=s390x-linux-gnu | FileCheck %s
; RUN: llc < %s -mtriple=s390x-linux-gnu | FileCheck %s -check-prefixes=CHECK,CHECK-LV
; RUN: llc < %s -mtriple=s390x-linux-gnu -early-live-intervals | FileCheck %s -check-prefixes=CHECK,CHECK-LIS
Copy link
Collaborator

Choose a reason for hiding this comment

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

These changes look redundant?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ugh. I am still struggling with how to deal with stacked patches. In the first commit the separate prefixes are necessary. In the second patch, codegen improves and they are no longer needed.

@@ -1,5 +1,6 @@
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mattr=+sse2 | FileCheck %s --check-prefixes=CHECK,SSE2
; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mattr=+sse2 | FileCheck %s --check-prefixes=CHECK,SSE2,SSE2-LV
; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mattr=+sse2 -early-live-intervals | FileCheck %s --check-prefixes=CHECK,SSE2,SSE2-LIS
Copy link
Collaborator

Choose a reason for hiding this comment

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

redundant change?

; CHECK-LIS-NEXT: pshufd {{.*#+}} xmm0 = xmm3[1,0,1,1]
; CHECK-LIS-NEXT: pblendw {{.*#+}} xmm2 = xmm1[0,1],xmm2[2,3,4,5,6,7]
; CHECK-LIS-NEXT: por %xmm0, %xmm2
; CHECK-LIS-NEXT: movdqa %xmm2, %xmm0
Copy link
Collaborator

Choose a reason for hiding this comment

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

We have similar issues with multiple zero vector registers, so normally I'd say this is acceptable but I'm worried this change might be encouraging the underlying problem?

@jayfoad
Copy link
Contributor Author

jayfoad commented Sep 12, 2023

Please can you update the patch title/description?

I will try to split this into two separate PRs, one for each commit. Please bear with me...

@jayfoad jayfoad changed the title processtiedpairs [TwoAddressInstruction] Use isPlainlyKilled in processTiedPairs Sep 12, 2023
@jayfoad
Copy link
Contributor Author

jayfoad commented Sep 12, 2023

The first commit (adding test coverage) is now #66058.

For this PR, please only review the second commit.

@jayfoad
Copy link
Contributor Author

jayfoad commented Sep 19, 2023

Rebased. Ping!

@@ -477,3 +451,6 @@ declare i5 @llvm.fshl.i5(i5, i5, i5)

declare <4 x i32> @llvm.fshl.v4i32(<4 x i32>, <4 x i32>, <4 x i32>)
declare <4 x i32> @llvm.fshr.v4i32(<4 x i32>, <4 x i32>, <4 x i32>)
;; NOTE: These prefixes are unused and the list is autogenerated. Do not add tests below this line:
; SSE2-LIS: {{.*}}
; SSE2-LV: {{.*}}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Remove these prefixes from the RUN lines?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

Calling isPlainlyKilled instead of directly checking for a kill flag
should make processTiedPairs behave the same with LiveIntervals
(i.e. when compiling with -early-live-intervals) as it does with
LiveVariables.
Copy link
Collaborator

@RKSimon RKSimon left a comment

Choose a reason for hiding this comment

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

LGTM

@jayfoad jayfoad merged commit 44e997a into llvm:main Sep 19, 2023
1 of 2 checks passed
@jayfoad jayfoad deleted the processtiedpairs branch September 19, 2023 15:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants