[llvm] [RISCV][GISEL] Add legalizer for G_BSWAP (PR #70226)
Michael Maitland via llvm-commits
llvm-commits at lists.llvm.org
Fri Oct 27 09:47:43 PDT 2023
================
@@ -68,77 +68,32 @@ body: |
; CHECK-NEXT: {{ $}}
; CHECK-NEXT: [[COPY:%[0-9]+]]:_(s32) = COPY $x10
; CHECK-NEXT: [[COPY1:%[0-9]+]]:_(s32) = COPY $x11
----------------
michaelmaitland wrote:
I based my test on [`test/CodeGen/RISCV/GlobalISel/legalizer/rv32/legalize-abs.mir` ](https://github.com/llvm/llvm-project/pull/67577/files#diff-6a8b6e95c4cf7713102e96d1e9ffe39f8c25697449dea448c3216cb623443bf3). I don't see the MIR tracking those properties. Can you explain how you know that we need them here and why we didn't for the G_ABS patch?
I have added `tracksRegLiveness: true` manually to all of the test cases in this patch. This property does not cause any diff in autogenerated test CHECKs. I then took that file and ran it through llc with the options you suggest (and -stop-after=legalizer) which generates something like:
```
...
---
name: bswap_i16
alignment: 1
exposesReturnsTwice: false
legalized: true
regBankSelected: false
selected: false
failedISel: false
tracksRegLiveness: true
hasWinCFI: false
callsEHReturn: false
callsUnwindInit: false
hasEHCatchret: false
hasEHScopes: false
hasEHFunclets: false
isOutlined: false
debugInstrRef: false
failsVerification: false
tracksDebugUserValues: false
registers:
- { id: 0, class: _, preferred-register: '' }
- { id: 1, class: _, preferred-register: '' }
- { id: 2, class: _, preferred-register: '' }
- { id: 3, class: _, preferred-register: '' }
- { id: 4, class: _, preferred-register: '' }
- { id: 5, class: _, preferred-register: '' }
- { id: 6, class: _, preferred-register: '' }
- { id: 7, class: _, preferred-register: '' }
- { id: 8, class: _, preferred-register: '' }
- { id: 9, class: _, preferred-register: '' }
- { id: 10, class: _, preferred-register: '' }
- { id: 11, class: _, preferred-register: '' }
- { id: 12, class: _, preferred-register: '' }
- { id: 13, class: _, preferred-register: '' }
- { id: 14, class: _, preferred-register: '' }
- { id: 15, class: _, preferred-register: '' }
- { id: 16, class: _, preferred-register: '' }
- { id: 17, class: _, preferred-register: '' }
- { id: 18, class: _, preferred-register: '' }
- { id: 19, class: _, preferred-register: '' }
- { id: 20, class: _, preferred-register: '' }
- { id: 21, class: _, preferred-register: '' }
- { id: 22, class: _, preferred-register: '' }
liveins: []
frameInfo:
isFrameAddressTaken: false
isReturnAddressTaken: false
hasStackMap: false
hasPatchPoint: false
stackSize: 0
offsetAdjustment: 0
maxAlignment: 1
adjustsStack: false
hasCalls: false
stackProtector: ''
functionContext: ''
maxCallFrameSize: 4294967295
cvBytesOfCalleeSavedRegisters: 0
hasOpaqueSPAdjustment: false
hasVAStart: false
hasMustTailInVarArgFunc: false
hasTailCall: false
localFrameSize: 0
savePoint: ''
restorePoint: ''
fixedStack: []
stack: []
entry_values: []
callSites: []
debugValueSubstitutions: []
constants: []
machineFunctionInfo:
varArgsFrameIndex: 0
varArgsSaveSize: 0
body: |
bb.0:
liveins: $x10
%0:_(s32) = COPY $x10
%1:_(s32) = G_ASSERT_ZEXT %0, 16
%15:_(s32) = G_CONSTANT i32 8
%17:_(s32) = G_SHL %1, %15(s32)
%12:_(s32) = G_CONSTANT i32 8
%20:_(s32) = G_CONSTANT i32 65535
%13:_(s32) = G_AND %1, %20
%14:_(s32) = G_LSHR %13, %12(s32)
%11:_(s32) = G_OR %14, %17
%22:_(s32) = G_CONSTANT i32 65535
%4:_(s32) = G_AND %11, %22
$x10 = COPY %4(s32)
PseudoRET implicit $x10
...
```
Do we really need to take any of these properties?
https://github.com/llvm/llvm-project/pull/70226
More information about the llvm-commits
mailing list