[llvm] [TwoAddressInstruction] Use isPlainlyKilled in processTiedPairs (PR #65976)
Jay Foad via llvm-commits
llvm-commits at lists.llvm.org
Tue Sep 19 07:35:41 PDT 2023
https://github.com/jayfoad updated https://github.com/llvm/llvm-project/pull/65976
>From d89ebf2ef880321c144d0ff241f7c6cf931bc66c Mon Sep 17 00:00:00 2001
From: Jay Foad <jay.foad at amd.com>
Date: Mon, 11 Sep 2023 14:04:24 +0100
Subject: [PATCH] [TwoAddressInstruction] Use isPlainlyKilled in
processTiedPairs
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.
---
.../lib/CodeGen/TwoAddressInstructionPass.cpp | 4 +-
llvm/test/CodeGen/SystemZ/rot-02.ll | 23 +++---
llvm/test/CodeGen/X86/combine-or.ll | 3 +-
llvm/test/CodeGen/X86/combine-rotates.ll | 77 +++++++------------
.../statepoint-cmp-sunk-past-statepoint.ll | 3 +-
5 files changed, 41 insertions(+), 69 deletions(-)
diff --git a/llvm/lib/CodeGen/TwoAddressInstructionPass.cpp b/llvm/lib/CodeGen/TwoAddressInstructionPass.cpp
index 560a0a4fbac66b3..4ae396723ef0977 100644
--- a/llvm/lib/CodeGen/TwoAddressInstructionPass.cpp
+++ b/llvm/lib/CodeGen/TwoAddressInstructionPass.cpp
@@ -1566,7 +1566,7 @@ TwoAddressInstructionPass::processTiedPairs(MachineInstr *MI,
MachineOperand &MO = MI->getOperand(SrcIdx);
assert(MO.isReg() && MO.getReg() == RegB && MO.isUse() &&
"inconsistent operand info for 2-reg pass");
- if (MO.isKill()) {
+ if (isPlainlyKilled(MO)) {
MO.setIsKill(false);
RemovedKillFlag = true;
}
@@ -1587,7 +1587,7 @@ TwoAddressInstructionPass::processTiedPairs(MachineInstr *MI,
for (MachineOperand &MO : MI->all_uses()) {
if (MO.getReg() == RegB) {
if (MO.getSubReg() == SubRegB && !IsEarlyClobber) {
- if (MO.isKill()) {
+ if (isPlainlyKilled(MO)) {
MO.setIsKill(false);
RemovedKillFlag = true;
}
diff --git a/llvm/test/CodeGen/SystemZ/rot-02.ll b/llvm/test/CodeGen/SystemZ/rot-02.ll
index 84fac6af5fcaa5e..a6cccdadf531898 100644
--- a/llvm/test/CodeGen/SystemZ/rot-02.ll
+++ b/llvm/test/CodeGen/SystemZ/rot-02.ll
@@ -76,20 +76,12 @@ define i64 @f4(i64 %val, i64 %amt) {
; Test that AND is not entirely removed if the result is reused.
define i32 @f5(i32 %val, i32 %amt) {
-; CHECK-LV-LABEL: f5:
-; CHECK-LV: # %bb.0:
-; CHECK-LV-NEXT: rll %r2, %r2, 0(%r3)
-; CHECK-LV-NEXT: nilf %r3, 63
-; CHECK-LV-NEXT: ar %r2, %r3
-; CHECK-LV-NEXT: br %r14
-;
-; CHECK-LIS-LABEL: f5:
-; CHECK-LIS: # %bb.0:
-; CHECK-LIS-NEXT: rll %r0, %r2, 0(%r3)
-; CHECK-LIS-NEXT: nilf %r3, 63
-; CHECK-LIS-NEXT: ar %r3, %r0
-; CHECK-LIS-NEXT: lr %r2, %r3
-; CHECK-LIS-NEXT: br %r14
+; CHECK-LABEL: f5:
+; CHECK: # %bb.0:
+; CHECK-NEXT: rll %r2, %r2, 0(%r3)
+; CHECK-NEXT: nilf %r3, 63
+; CHECK-NEXT: ar %r2, %r3
+; CHECK-NEXT: br %r14
%and = and i32 %amt, 63
%inv = sub i32 32, %and
@@ -101,3 +93,6 @@ define i32 @f5(i32 %val, i32 %amt) {
%reuse = add i32 %and, %rotl
ret i32 %reuse
}
+;; NOTE: These prefixes are unused and the list is autogenerated. Do not add tests below this line:
+; CHECK-LIS: {{.*}}
+; CHECK-LV: {{.*}}
diff --git a/llvm/test/CodeGen/X86/combine-or.ll b/llvm/test/CodeGen/X86/combine-or.ll
index bfb9885c10c4e5d..460251ffa6c5dfd 100644
--- a/llvm/test/CodeGen/X86/combine-or.ll
+++ b/llvm/test/CodeGen/X86/combine-or.ll
@@ -253,7 +253,8 @@ define <4 x i32> @test18(<4 x i32> %a, <4 x i32> %b) {
; CHECK-LIS-NEXT: pblendw {{.*#+}} xmm3 = xmm0[0,1],xmm3[2,3,4,5,6,7]
; 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 %xmm2, %xmm0
+; CHECK-LIS-NEXT: por %xmm0, %xmm2
+; CHECK-LIS-NEXT: movdqa %xmm2, %xmm0
; CHECK-LIS-NEXT: retq
%shuf1 = shufflevector <4 x i32> %a, <4 x i32> zeroinitializer, <4 x i32><i32 4, i32 0, i32 4, i32 4>
%shuf2 = shufflevector <4 x i32> %b, <4 x i32> zeroinitializer, <4 x i32><i32 0, i32 4, i32 4, i32 4>
diff --git a/llvm/test/CodeGen/X86/combine-rotates.ll b/llvm/test/CodeGen/X86/combine-rotates.ll
index 8e43ae438f2aeeb..2d7c4a457548069 100644
--- a/llvm/test/CodeGen/X86/combine-rotates.ll
+++ b/llvm/test/CodeGen/X86/combine-rotates.ll
@@ -115,56 +115,30 @@ define i32 @combine_rot_select_zero(i32, i32) {
}
define <4 x i32> @combine_vec_rot_select_zero(<4 x i32>, <4 x i32>) {
-; SSE2-LV-LABEL: combine_vec_rot_select_zero:
-; SSE2-LV: # %bb.0:
-; SSE2-LV-NEXT: pxor %xmm2, %xmm2
-; SSE2-LV-NEXT: pcmpeqd %xmm1, %xmm2
-; SSE2-LV-NEXT: pslld $23, %xmm1
-; SSE2-LV-NEXT: pand {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm1
-; SSE2-LV-NEXT: paddd {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm1
-; SSE2-LV-NEXT: cvttps2dq %xmm1, %xmm1
-; SSE2-LV-NEXT: movdqa %xmm0, %xmm3
-; SSE2-LV-NEXT: pmuludq %xmm1, %xmm3
-; SSE2-LV-NEXT: pshufd {{.*#+}} xmm4 = xmm3[1,3,2,3]
-; SSE2-LV-NEXT: pshufd {{.*#+}} xmm5 = xmm0[1,1,3,3]
-; SSE2-LV-NEXT: pshufd {{.*#+}} xmm1 = xmm1[1,1,3,3]
-; SSE2-LV-NEXT: pmuludq %xmm5, %xmm1
-; SSE2-LV-NEXT: pshufd {{.*#+}} xmm5 = xmm1[1,3,2,3]
-; SSE2-LV-NEXT: punpckldq {{.*#+}} xmm4 = xmm4[0],xmm5[0],xmm4[1],xmm5[1]
-; SSE2-LV-NEXT: pshufd {{.*#+}} xmm3 = xmm3[0,2,2,3]
-; SSE2-LV-NEXT: pshufd {{.*#+}} xmm1 = xmm1[0,2,2,3]
-; SSE2-LV-NEXT: punpckldq {{.*#+}} xmm3 = xmm3[0],xmm1[0],xmm3[1],xmm1[1]
-; SSE2-LV-NEXT: por %xmm4, %xmm3
-; SSE2-LV-NEXT: pand %xmm2, %xmm0
-; SSE2-LV-NEXT: pandn %xmm3, %xmm2
-; SSE2-LV-NEXT: por %xmm2, %xmm0
-; SSE2-LV-NEXT: retq
-;
-; SSE2-LIS-LABEL: combine_vec_rot_select_zero:
-; SSE2-LIS: # %bb.0:
-; SSE2-LIS-NEXT: movdqa %xmm0, %xmm2
-; SSE2-LIS-NEXT: pxor %xmm0, %xmm0
-; SSE2-LIS-NEXT: pcmpeqd %xmm1, %xmm0
-; SSE2-LIS-NEXT: pslld $23, %xmm1
-; SSE2-LIS-NEXT: pand {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm1
-; SSE2-LIS-NEXT: paddd {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm1
-; SSE2-LIS-NEXT: cvttps2dq %xmm1, %xmm1
-; SSE2-LIS-NEXT: movdqa %xmm2, %xmm3
-; SSE2-LIS-NEXT: pmuludq %xmm1, %xmm3
-; SSE2-LIS-NEXT: pshufd {{.*#+}} xmm4 = xmm3[1,3,2,3]
-; SSE2-LIS-NEXT: pshufd {{.*#+}} xmm5 = xmm2[1,1,3,3]
-; SSE2-LIS-NEXT: pshufd {{.*#+}} xmm1 = xmm1[1,1,3,3]
-; SSE2-LIS-NEXT: pmuludq %xmm5, %xmm1
-; SSE2-LIS-NEXT: pshufd {{.*#+}} xmm5 = xmm1[1,3,2,3]
-; SSE2-LIS-NEXT: punpckldq {{.*#+}} xmm4 = xmm4[0],xmm5[0],xmm4[1],xmm5[1]
-; SSE2-LIS-NEXT: pshufd {{.*#+}} xmm3 = xmm3[0,2,2,3]
-; SSE2-LIS-NEXT: pshufd {{.*#+}} xmm1 = xmm1[0,2,2,3]
-; SSE2-LIS-NEXT: punpckldq {{.*#+}} xmm3 = xmm3[0],xmm1[0],xmm3[1],xmm1[1]
-; SSE2-LIS-NEXT: por %xmm4, %xmm3
-; SSE2-LIS-NEXT: pand %xmm0, %xmm2
-; SSE2-LIS-NEXT: pandn %xmm3, %xmm0
-; SSE2-LIS-NEXT: por %xmm2, %xmm0
-; SSE2-LIS-NEXT: retq
+; SSE2-LABEL: combine_vec_rot_select_zero:
+; SSE2: # %bb.0:
+; SSE2-NEXT: pxor %xmm2, %xmm2
+; SSE2-NEXT: pcmpeqd %xmm1, %xmm2
+; SSE2-NEXT: pslld $23, %xmm1
+; SSE2-NEXT: pand {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm1
+; SSE2-NEXT: paddd {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm1
+; SSE2-NEXT: cvttps2dq %xmm1, %xmm1
+; SSE2-NEXT: movdqa %xmm0, %xmm3
+; SSE2-NEXT: pmuludq %xmm1, %xmm3
+; SSE2-NEXT: pshufd {{.*#+}} xmm4 = xmm3[1,3,2,3]
+; SSE2-NEXT: pshufd {{.*#+}} xmm5 = xmm0[1,1,3,3]
+; SSE2-NEXT: pshufd {{.*#+}} xmm1 = xmm1[1,1,3,3]
+; SSE2-NEXT: pmuludq %xmm5, %xmm1
+; SSE2-NEXT: pshufd {{.*#+}} xmm5 = xmm1[1,3,2,3]
+; SSE2-NEXT: punpckldq {{.*#+}} xmm4 = xmm4[0],xmm5[0],xmm4[1],xmm5[1]
+; SSE2-NEXT: pshufd {{.*#+}} xmm3 = xmm3[0,2,2,3]
+; SSE2-NEXT: pshufd {{.*#+}} xmm1 = xmm1[0,2,2,3]
+; SSE2-NEXT: punpckldq {{.*#+}} xmm3 = xmm3[0],xmm1[0],xmm3[1],xmm1[1]
+; SSE2-NEXT: por %xmm4, %xmm3
+; SSE2-NEXT: pand %xmm2, %xmm0
+; SSE2-NEXT: pandn %xmm3, %xmm2
+; SSE2-NEXT: por %xmm2, %xmm0
+; SSE2-NEXT: retq
;
; XOP-LABEL: combine_vec_rot_select_zero:
; XOP: # %bb.0:
@@ -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: {{.*}}
diff --git a/llvm/test/CodeGen/X86/statepoint-cmp-sunk-past-statepoint.ll b/llvm/test/CodeGen/X86/statepoint-cmp-sunk-past-statepoint.ll
index 63b2a9d415041c6..731cc95114f7780 100644
--- a/llvm/test/CodeGen/X86/statepoint-cmp-sunk-past-statepoint.ll
+++ b/llvm/test/CodeGen/X86/statepoint-cmp-sunk-past-statepoint.ll
@@ -61,8 +61,7 @@ zero:
; CHECK: bb.4
; CHECK: bb.5
; CHECK: %3:gr64 = COPY %10
-; CHECK-LV: %4:gr64 = COPY killed %10
-; CHECK-LIS: %4:gr64 = COPY %10
+; CHECK: %4:gr64 = COPY killed %10
; CHECK: %4:gr64 = nuw ADD64ri32 %4, 8, implicit-def dead $eflags
; CHECK: TEST64rr killed %1, %1, implicit-def $eflags
; CHECK: JCC_1 %bb.1, 5, implicit killed $eflags
More information about the llvm-commits
mailing list