GlobalISel: Guard return in llvm::getIConstantSplatVal (#71989)
getIConstantVRegValWithLookThrough could return NULL.
This commit is contained in:
parent
d2fd1106f6
commit
011c9eeb9a
@ -1116,9 +1116,9 @@ std::optional<APInt>
|
||||
llvm::getIConstantSplatVal(const Register Reg, const MachineRegisterInfo &MRI) {
|
||||
if (auto SplatValAndReg =
|
||||
getAnyConstantSplat(Reg, MRI, /* AllowUndef */ false)) {
|
||||
std::optional<ValueAndVReg> ValAndVReg =
|
||||
getIConstantVRegValWithLookThrough(SplatValAndReg->VReg, MRI);
|
||||
return ValAndVReg->Value;
|
||||
if (std::optional<ValueAndVReg> ValAndVReg =
|
||||
getIConstantVRegValWithLookThrough(SplatValAndReg->VReg, MRI))
|
||||
return ValAndVReg->Value;
|
||||
}
|
||||
|
||||
return std::nullopt;
|
||||
|
||||
@ -0,0 +1,26 @@
|
||||
# NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py UTC_ARGS: --version 3
|
||||
# RUN: llc -march=amdgcn -mcpu=gfx1030 -run-pass amdgpu-prelegalizer-combiner %s -o - | FileCheck -check-prefix=GCN %s
|
||||
|
||||
---
|
||||
name: non_inlineable_imm_splat
|
||||
body: |
|
||||
bb.1:
|
||||
liveins: $vgpr0
|
||||
|
||||
; GCN-LABEL: name: non_inlineable_imm_splat
|
||||
; GCN: liveins: $vgpr0
|
||||
; GCN-NEXT: {{ $}}
|
||||
; GCN-NEXT: [[COPY:%[0-9]+]]:_(<2 x s16>) = COPY $vgpr0
|
||||
; GCN-NEXT: [[C:%[0-9]+]]:_(s16) = G_FCONSTANT half 0xH4200
|
||||
; GCN-NEXT: [[BUILD_VECTOR:%[0-9]+]]:_(<2 x s16>) = G_BUILD_VECTOR [[C]](s16), [[C]](s16)
|
||||
; GCN-NEXT: [[SUB:%[0-9]+]]:_(<2 x s16>) = G_SUB [[COPY]], [[BUILD_VECTOR]]
|
||||
; GCN-NEXT: $vgpr0 = COPY [[SUB]](<2 x s16>)
|
||||
; GCN-NEXT: SI_RETURN implicit $vgpr0
|
||||
%0:_(<2 x s16>) = COPY $vgpr0
|
||||
%2:_(s16) = G_FCONSTANT half 0xH4200
|
||||
%1:_(<2 x s16>) = G_BUILD_VECTOR %2(s16), %2(s16)
|
||||
%3:_(<2 x s16>) = G_SUB %0, %1
|
||||
$vgpr0 = COPY %3(<2 x s16>)
|
||||
SI_RETURN implicit $vgpr0
|
||||
|
||||
...
|
||||
Loading…
x
Reference in New Issue
Block a user