[llvm] [GlobalISel][AArch64] Improve legalization of shift amounts (PR #208676)
Ömer Sinan Ağacan via llvm-commits
llvm-commits at lists.llvm.org
Fri Jul 10 03:48:46 PDT 2026
osa1 wrote:
@cofibrant it crashes without the patch. IR:
```
define i8 @test(i48 %a) {
entry:
%b = lshr i48 %a, 15
%c = trunc i48 %b to i8
ret i8 %c
}
```
With `llc -stop-before=legalizer -global-isel`:
```
--- |
; ModuleID = 'lshr_crash.ll'
source_filename = "lshr_crash.ll"
target datalayout = "e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-n32:64-S128-Fn32"
define i8 @test(i48 %a) {
entry:
%b = lshr i48 %a, 15
%c = trunc i48 %b to i8
ret i8 %c
}
...
---
name: test
alignment: 4
exposesReturnsTwice: false
legalized: false
regBankSelected: false
selected: false
failedISel: false
tracksRegLiveness: true
hasWinCFI: false
noPhis: false
isSSA: true
noVRegs: false
hasFakeUses: false
callsEHReturn: false
callsUnwindInit: false
hasEHContTarget: false
hasEHScopes: false
hasEHFunclets: false
isOutlined: false
debugInstrRef: false
failsVerification: false
tracksDebugUserValues: false
registers:
- { id: 0, class: _, preferred-register: '', flags: [ ] }
- { id: 1, class: _, preferred-register: '', flags: [ ] }
- { id: 2, class: _, preferred-register: '', flags: [ ] }
- { id: 3, class: _, preferred-register: '', flags: [ ] }
- { id: 4, class: _, preferred-register: '', flags: [ ] }
- { id: 5, class: _, preferred-register: '', flags: [ ] }
- { id: 6, class: _, preferred-register: '', flags: [ ] }
- { id: 7, class: _, preferred-register: '', flags: [ ] }
liveins:
- { reg: '$x0', virtual-reg: '' }
frameInfo:
isFrameAddressTaken: false
isReturnAddressTaken: false
hasStackMap: false
hasPatchPoint: false
stackSize: 0
offsetAdjustment: 0
maxAlignment: 1
adjustsStack: false
hasCalls: false
framePointerPolicy: none
stackProtector: ''
functionContext: ''
maxCallFrameSize: 4294967295
cvBytesOfCalleeSavedRegisters: 0
hasOpaqueSPAdjustment: false
hasVAStart: false
hasMustTailInVarArgFunc: false
hasTailCall: false
isCalleeSavedInfoValid: false
localFrameSize: 0
fixedStack: []
stack: []
entry_values: []
callSites: []
debugValueSubstitutions: []
constants: []
machineFunctionInfo: {}
body: |
bb.1.entry:
liveins: $x0
%1:_(i64) = COPY $x0
%0:_(i48) = G_TRUNC %1(i64)
%6:_(i32) = G_TRUNC %0(i48)
%2:_(i48) = G_CONSTANT i48 15
%7:_(i32) = G_LSHR %6, %2(i48)
$w0 = COPY %7(i32)
RET_ReallyLR implicit $w0
...
```
If you run legalizer it crashes, so there's no output before this PR.
https://github.com/llvm/llvm-project/pull/208676
More information about the llvm-commits
mailing list