Skip to content

Commit 98e95a0

Browse files
authored
[AMDGPU] Make S_MOV_B64_IMM_PSEUDO foldable (#69483)
With the legality checks in place it is now safe to do. S_MOV_B64 shall not be used with wide literals, thus updating the test.
1 parent 6c6749c commit 98e95a0

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

llvm/lib/Target/AMDGPU/SIInstrInfo.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3170,6 +3170,7 @@ bool SIInstrInfo::isFoldableCopy(const MachineInstr &MI) {
31703170
case AMDGPU::V_MOV_B64_e64:
31713171
case AMDGPU::S_MOV_B32:
31723172
case AMDGPU::S_MOV_B64:
3173+
case AMDGPU::S_MOV_B64_IMM_PSEUDO:
31733174
case AMDGPU::COPY:
31743175
case AMDGPU::WWM_COPY:
31753176
case AMDGPU::V_ACCVGPR_WRITE_B32_e64:

llvm/test/CodeGen/AMDGPU/fold-short-64-bit-literals.mir

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@ body: |
99
1010
; GCN-LABEL: name: no_fold_fp_64bit_literal_sgpr
1111
; GCN: [[DEF:%[0-9]+]]:vreg_64 = IMPLICIT_DEF
12-
; GCN-NEXT: [[S_MOV_B64_:%[0-9]+]]:sreg_64 = S_MOV_B64 1311768467750121200
13-
; GCN-NEXT: [[V_ADD_F64_e64_:%[0-9]+]]:vreg_64 = V_ADD_F64_e64 0, [[S_MOV_B64_]], 0, [[DEF]], 0, 0, implicit $mode, implicit $exec
12+
; GCN-NEXT: [[S_MOV_B:%[0-9]+]]:sreg_64 = S_MOV_B64_IMM_PSEUDO 1311768467750121200
13+
; GCN-NEXT: [[V_ADD_F64_e64_:%[0-9]+]]:vreg_64 = V_ADD_F64_e64 0, [[S_MOV_B]], 0, [[DEF]], 0, 0, implicit $mode, implicit $exec
1414
; GCN-NEXT: SI_RETURN_TO_EPILOG [[V_ADD_F64_e64_]]
1515
%0:vreg_64 = IMPLICIT_DEF
16-
%1:sreg_64 = S_MOV_B64 1311768467750121200
16+
%1:sreg_64 = S_MOV_B64_IMM_PSEUDO 1311768467750121200
1717
%2:vreg_64 = V_ADD_F64_e64 0, %1, 0, %0, 0, 0, implicit $mode, implicit $exec
1818
SI_RETURN_TO_EPILOG %2
1919
...
@@ -46,7 +46,7 @@ body: |
4646
; GCN-NEXT: [[V_ADD_F64_e64_:%[0-9]+]]:vreg_64 = V_ADD_F64_e64 0, 4636737291354636288, 0, [[DEF]], 0, 0, implicit $mode, implicit $exec
4747
; GCN-NEXT: SI_RETURN_TO_EPILOG [[V_ADD_F64_e64_]]
4848
%0:vreg_64 = IMPLICIT_DEF
49-
%1:sreg_64 = S_MOV_B64 4636737291354636288
49+
%1:sreg_64 = S_MOV_B64_IMM_PSEUDO 4636737291354636288
5050
%2:vreg_64 = V_ADD_F64_e64 0, %1, 0, %0, 0, 0, implicit $mode, implicit $exec
5151
SI_RETURN_TO_EPILOG %2
5252
...
@@ -59,11 +59,11 @@ body: |
5959
6060
; GCN-LABEL: name: no_fold_int_64bit_literal_sgpr
6161
; GCN: [[DEF:%[0-9]+]]:sreg_64 = IMPLICIT_DEF
62-
; GCN-NEXT: [[S_MOV_B64_:%[0-9]+]]:sreg_64 = S_MOV_B64 1311768467750121200
63-
; GCN-NEXT: [[S_AND_B64_:%[0-9]+]]:sreg_64 = S_AND_B64 [[DEF]], [[S_MOV_B64_]], implicit-def $scc
62+
; GCN-NEXT: [[S_MOV_B:%[0-9]+]]:sreg_64 = S_MOV_B64_IMM_PSEUDO 1311768467750121200
63+
; GCN-NEXT: [[S_AND_B64_:%[0-9]+]]:sreg_64 = S_AND_B64 [[DEF]], [[S_MOV_B]], implicit-def $scc
6464
; GCN-NEXT: SI_RETURN_TO_EPILOG [[S_AND_B64_]]
6565
%0:sreg_64 = IMPLICIT_DEF
66-
%1:sreg_64 = S_MOV_B64 1311768467750121200
66+
%1:sreg_64 = S_MOV_B64_IMM_PSEUDO 1311768467750121200
6767
%2:sreg_64 = S_AND_B64 %0, %1, implicit-def $scc
6868
SI_RETURN_TO_EPILOG %2
6969
...

0 commit comments

Comments
 (0)