Skip to content

Commit b5b8a59

Browse files
authored
AMDGPU: Implement getRequiredProperties for SIFoldOperands (#127522)
Fix the broken MIR tests violating isSSA.
1 parent ed38d67 commit b5b8a59

File tree

3 files changed

+31
-20
lines changed

3 files changed

+31
-20
lines changed

llvm/lib/Target/AMDGPU/SIFoldOperands.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,11 @@ class SIFoldOperandsLegacy : public MachineFunctionPass {
166166
AU.setPreservesCFG();
167167
MachineFunctionPass::getAnalysisUsage(AU);
168168
}
169+
170+
MachineFunctionProperties getRequiredProperties() const override {
171+
return MachineFunctionProperties().set(
172+
MachineFunctionProperties::Property::IsSSA);
173+
}
169174
};
170175

171176
} // End anonymous namespace.

llvm/lib/Target/AMDGPU/SIFoldOperands.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,11 @@ class SIFoldOperandsPass : public PassInfoMixin<SIFoldOperandsPass> {
1717
SIFoldOperandsPass() = default;
1818
PreservedAnalyses run(MachineFunction &MF,
1919
MachineFunctionAnalysisManager &MFAM);
20+
21+
MachineFunctionProperties getRequiredProperties() const {
22+
return MachineFunctionProperties().set(
23+
MachineFunctionProperties::Property::IsSSA);
24+
}
2025
};
2126
} // namespace llvm
2227

llvm/test/CodeGen/AMDGPU/constant-fold-imm-immreg.mir

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,8 @@ body: |
9696
%12:vgpr_32 = V_AND_B32_e64 %8, %8, implicit $exec
9797
FLAT_STORE_DWORD %19, %12, 0, 0, implicit $exec, implicit $flat_scr
9898
99-
%13:vgpr_32 = V_AND_B32_e64 %16, %16, implicit $exec
100-
FLAT_STORE_DWORD %19, %13, 0, 0, implicit $exec, implicit $flat_scr
99+
%21:vgpr_32 = V_AND_B32_e64 %16, %16, implicit $exec
100+
FLAT_STORE_DWORD %19, %21, 0, 0, implicit $exec, implicit $flat_scr
101101
102102
S_ENDPGM 0
103103
@@ -191,6 +191,7 @@ body: |
191191

192192
name: v_fold_ashr_imm_regimm_32
193193
tracksRegLiveness: true
194+
isSSA: true
194195
liveins:
195196
- { reg: '$sgpr0_sgpr1', virtual-reg: '%0' }
196197
- { reg: '$vgpr0', virtual-reg: '%2' }
@@ -232,8 +233,8 @@ body: |
232233
%14:vgpr_32 = V_ASHR_I32_e64 7, %29, implicit $exec
233234
FLAT_STORE_DWORD %20, %14, 0, 0, implicit $exec, implicit $flat_scr
234235
235-
%15:vgpr_32 = V_ASHR_I32_e64 %27, %24, implicit $exec
236-
FLAT_STORE_DWORD %20, %15, 0, 0, implicit $exec, implicit $flat_scr
236+
%33:vgpr_32 = V_ASHR_I32_e64 %27, %24, implicit $exec
237+
FLAT_STORE_DWORD %20, %33, 0, 0, implicit $exec, implicit $flat_scr
237238
238239
%22:vgpr_32 = V_ASHR_I32_e64 %6, 4, implicit $exec
239240
FLAT_STORE_DWORD %20, %22, 0, 0, implicit $exec, implicit $flat_scr
@@ -356,8 +357,8 @@ body: |
356357
%14:vgpr_32 = V_LSHR_B32_e64 7, %29, implicit $exec
357358
FLAT_STORE_DWORD %20, %14, 0, 0, implicit $exec, implicit $flat_scr
358359
359-
%15:vgpr_32 = V_LSHR_B32_e64 %27, %24, implicit $exec
360-
FLAT_STORE_DWORD %20, %15, 0, 0, implicit $exec, implicit $flat_scr
360+
%33:vgpr_32 = V_LSHR_B32_e64 %27, %24, implicit $exec
361+
FLAT_STORE_DWORD %20, %33, 0, 0, implicit $exec, implicit $flat_scr
361362
362363
%22:vgpr_32 = V_LSHR_B32_e64 %6, 4, implicit $exec
363364
FLAT_STORE_DWORD %20, %22, 0, 0, implicit $exec, implicit $flat_scr
@@ -497,8 +498,8 @@ body: |
497498
# GCN: %17:vgpr_32 = V_MOV_B32_e32 1234567, implicit $exec
498499
# GCN: FLAT_STORE_DWORD %10, %17,
499500

500-
# GCN: %3:vgpr_32 = V_MOV_B32_e32 63, implicit $exec
501-
# GCN: FLAT_STORE_DWORD %10, %3,
501+
# GCN: %18:vgpr_32 = V_MOV_B32_e32 63, implicit $exec
502+
# GCN: FLAT_STORE_DWORD %10, %18,
502503

503504
name: v_fold_or_imm_regimm_32
504505
alignment: 0
@@ -536,8 +537,8 @@ body: |
536537
FLAT_STORE_DWORD %19, %11, 0, 0, implicit $exec, implicit $flat_scr
537538
%12:vgpr_32 = V_OR_B32_e64 %8, %8, implicit $exec
538539
FLAT_STORE_DWORD %19, %12, 0, 0, implicit $exec, implicit $flat_scr
539-
%13:vgpr_32 = V_OR_B32_e64 %16, %16, implicit $exec
540-
FLAT_STORE_DWORD %19, %13, 0, 0, implicit $exec, implicit $flat_scr
540+
%21:vgpr_32 = V_OR_B32_e64 %16, %16, implicit $exec
541+
FLAT_STORE_DWORD %19, %21, 0, 0, implicit $exec, implicit $flat_scr
541542
S_ENDPGM 0
542543
543544
...
@@ -689,24 +690,24 @@ body: |
689690
# GCN: %19:vgpr_32 = V_MOV_B32_e32 24, implicit $exec
690691
# GCN: FLAT_STORE_DWORD %10, %19,
691692

692-
# GCN: %3:vgpr_32 = V_MOV_B32_e32 0, implicit $exec
693-
# GCN: FLAT_STORE_DWORD %10, %3,
694-
695-
# GCN: %20:vgpr_32 = V_MOV_B32_e32 4096, implicit $exec
693+
# GCN: %20:vgpr_32 = V_MOV_B32_e32 0, implicit $exec
696694
# GCN: FLAT_STORE_DWORD %10, %20,
697695

698-
# GCN: %21:vgpr_32 = V_MOV_B32_e32 1, implicit $exec
696+
# GCN: %21:vgpr_32 = V_MOV_B32_e32 4096, implicit $exec
699697
# GCN: FLAT_STORE_DWORD %10, %21,
700698

701-
# GCN: %22:vgpr_32 = V_MOV_B32_e32 2, implicit $exec
699+
# GCN: %22:vgpr_32 = V_MOV_B32_e32 1, implicit $exec
702700
# GCN: FLAT_STORE_DWORD %10, %22,
703701

704-
# GCN: %23:vgpr_32 = V_MOV_B32_e32 7927808, implicit $exec
702+
# GCN: %23:vgpr_32 = V_MOV_B32_e32 2, implicit $exec
705703
# GCN: FLAT_STORE_DWORD %10, %23,
706704

707-
# GCN: %24:vgpr_32 = V_MOV_B32_e32 -8, implicit $exec
705+
# GCN: %24:vgpr_32 = V_MOV_B32_e32 7927808, implicit $exec
708706
# GCN: FLAT_STORE_DWORD %10, %24,
709707

708+
# GCN: %25:vgpr_32 = V_MOV_B32_e32 -8, implicit $exec
709+
# GCN: FLAT_STORE_DWORD %10, %25,
710+
710711
name: v_fold_shl_imm_regimm_32
711712
alignment: 0
712713
exposesReturnsTwice: false
@@ -745,8 +746,8 @@ body: |
745746
FLAT_STORE_DWORD %20, %13, 0, 0, implicit $exec, implicit $flat_scr
746747
%14:vgpr_32 = V_LSHL_B32_e64 12, %7, implicit $exec
747748
FLAT_STORE_DWORD %20, %14, 0, 0, implicit $exec, implicit $flat_scr
748-
%15:vgpr_32 = V_LSHL_B32_e64 12, %24, implicit $exec
749-
FLAT_STORE_DWORD %20, %15, 0, 0, implicit $exec, implicit $flat_scr
749+
%30:vgpr_32 = V_LSHL_B32_e64 12, %24, implicit $exec
750+
FLAT_STORE_DWORD %20, %30, 0, 0, implicit $exec, implicit $flat_scr
750751
%22:vgpr_32 = V_LSHL_B32_e64 %6, 12, implicit $exec
751752
FLAT_STORE_DWORD %20, %22, 0, 0, implicit $exec, implicit $flat_scr
752753
%23:vgpr_32 = V_LSHL_B32_e64 %6, 32, implicit $exec

0 commit comments

Comments
 (0)