<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/114816>114816</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Legalization of `@llvm.vector.reduce.fmax.v4f32` unsupported for AMDGPU using global-isel
</td>
</tr>
<tr>
<th>Labels</th>
<td>
backend:AMDGPU,
llvm:globalisel
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
tpopp
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
tpopp
</td>
</tr>
</table>
<pre>
Attempting to lower the following code snippet with global isel fails in legalization:`llc -global-isel reduced.ll`
```
target datalayout = "e-p:64:64-p1:64:64-p2:32:32-p3:32:32-p4:64:64-p5:32:32-p6:32:32-p7:160:256:256:32-p8:128:128-p9:192:256:256:32-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-v2048:2048-n32:64-S32-A5-G1-ni:7:8:9"
target triple = "amdgcn-amd-amdhsa"
define amdgpu_kernel void @"main$async_dispatch_19_softmax_16384x16384xf32_dispatch_tensor_store"() {
%1 = call float @llvm.vector.reduce.fmax.v4f32(<4 x float> zeroinitializer)
store float %1, ptr addrspace(3) null, align 4
ret void
}
; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare float @llvm.vector.reduce.fmax.v4f32(<4 x float>) #0
attributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
```
```
# *** IR Dump Before Legalizer (legalizer) ***:
# Machine code for function main$async_dispatch_19_softmax_16384x16384xf32_dispatch_tensor_store: IsSSA, TracksLiveness
Function Live Ins: $sgpr0_sgpr1_sgpr2_sgpr3 in %0, $sgpr4_sgpr5 in %1, $sgpr6_sgpr7 in %2, $sgpr8_sgpr9 in %3, $vgpr0 in %4, $vgpr1 in %5, $vgpr2 in %6, $sgpr10 in %7, $sgpr11 in %8, $sgpr12 in %9, $sgpr13 in %10
bb.1 (%ir-block.0):
liveins: $sgpr6_sgpr7
%12:_(s32) = G_FCONSTANT float 0.000000e+00
%11:_(<4 x s32>) = G_BUILD_VECTOR %12:_(s32), %12:_(s32), %12:_(s32), %12:_(s32)
%13:_(s32) = G_VECREDUCE_FMAX %11:_(<4 x s32>)
%14:_(p3) = G_CONSTANT i32 0
G_STORE %13:_(s32), %14:_(p3) :: (store (s32) into `ptr addrspace(3) null`, addrspace 3)
S_ENDPGM 0
# End machine code for function main$async_dispatch_19_softmax_16384x16384xf32_dispatch_tensor_store.
LLVM ERROR: unable to legalize instruction: %13:_(s32) = G_VECREDUCE_FMAX %11:_(<4 x s32>) (in function: main$async_dispatch_19_softmax_16384x16384xf32_dispatch_tensor_store)
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0. Program arguments: /home/tpopp/gisel/iree-build/llvm-project/bin/llc -global-isel reduced.ll
1. Running pass 'CallGraph Pass Manager' on module 'reduced.ll'.
2. Running pass 'Legalizer' on function '@"main$async_dispatch_19_softmax_16384x16384xf32_dispatch_tensor_store"'
#0 0x000062d303317d87 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) /home/tpopp/gisel/iree/third_party/llvm-project/llvm/lib/Support/Unix/Signals.inc:723:13
#1 0x000062d303315fc0 llvm::sys::RunSignalHandlers() /home/tpopp/gisel/iree/third_party/llvm-project/llvm/lib/Support/Signals.cpp:106:18
#2 0x000062d30331844a SignalHandler(int) /home/tpopp/gisel/iree/third_party/llvm-project/llvm/lib/Support/Unix/Signals.inc:413:1
#3 0x000075c0bba42520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
#4 0x000075c0bba969fc __pthread_kill_implementation ./nptl/./nptl/pthread_kill.c:44:76
#5 0x000075c0bba969fc __pthread_kill_internal ./nptl/./nptl/pthread_kill.c:78:10
#6 0x000075c0bba969fc pthread_kill ./nptl/./nptl/pthread_kill.c:89:10
#7 0x000075c0bba42476 gsignal ./signal/../sysdeps/posix/raise.c:27:6
#8 0x000075c0bba287f3 abort ./stdlib/./stdlib/abort.c:81:7
#9 0x000062d30328c7b3 llvm::report_fatal_error(llvm::Twine const&, bool) /home/tpopp/gisel/iree/third_party/llvm-project/llvm/lib/Support/ErrorHandling.cpp:126:5
#10 0x000062d3037c26e4 (/home/tpopp/gisel/iree-build/llvm-project/bin/llc+0x604b6e4)
#11 0x000062d3037c29c8 llvm::DiagnosticInfoOptimizationBase::~DiagnosticInfoOptimizationBase() /home/tpopp/gisel/iree/third_party/llvm-project/llvm/include/llvm/IR/DiagnosticInfo.h:414:7
#12 0x000062d3037c29c8 llvm::reportGISelFailure(llvm::MachineFunction&, llvm::TargetPassConfig const&, llvm::MachineOptimizationRemarkEmitter&, char const*, llvm::StringRef, llvm::MachineInstr const&) /home/tpopp/gisel/iree/third_party/llvm-project/llvm/lib/CodeGen/GlobalISel/Utils.cpp:277:1
#13 0x000062d30375bffd llvm::Legalizer::runOnMachineFunction(llvm::MachineFunction&) /home/tpopp/gisel/iree/third_party/llvm-project/llvm/lib/CodeGen/GlobalISel/Legalizer.cpp:0:5
#14 0x000062d30254d4c4 llvm::MachineFunctionPass::runOnFunction(llvm::Function&) /home/tpopp/gisel/iree/third_party/llvm-project/llvm/lib/CodeGen/MachineFunctionPass.cpp:0:13
#15 0x000062d3029ca875 llvm::FPPassManager::runOnFunction(llvm::Function&) /home/tpopp/gisel/iree/third_party/llvm-project/llvm/lib/IR/LegacyPassManager.cpp:0:27
#16 0x000062d3020c143c (anonymous namespace)::CGPassManager::RunPassOnSCC(llvm::Pass*, llvm::CallGraphSCC&, llvm::CallGraph&, bool&, bool&) /home/tpopp/gisel/iree/third_party/llvm-project/llvm/lib/Analysis/CallGraphSCCPass.cpp:180:25
#17 0x000062d3020c143c (anonymous namespace)::CGPassManager::RunAllPassesOnSCC(llvm::CallGraphSCC&, llvm::CallGraph&, bool&) /home/tpopp/gisel/iree/third_party/llvm-project/llvm/lib/Analysis/CallGraphSCCPass.cpp:469:9
#18 0x000062d3020c143c (anonymous namespace)::CGPassManager::runOnModule(llvm::Module&) /home/tpopp/gisel/iree/third_party/llvm-project/llvm/lib/Analysis/CallGraphSCCPass.cpp:534:18
#19 0x000062d3029cb002 llvm::legacy::PassManagerImpl::run(llvm::Module&) /home/tpopp/gisel/iree/third_party/llvm-project/llvm/lib/IR/LegacyPassManager.cpp:0:27
#20 0x000062d3010b25e3 compileModule(char**, llvm::LLVMContext&) /home/tpopp/gisel/iree/third_party/llvm-project/llvm/tools/llc/llc.cpp:755:17
#21 0x000062d3010b25e3 main /home/tpopp/gisel/iree/third_party/llvm-project/llvm/tools/llc/llc.cpp:412:22
#22 0x000075c0bba29d90 __libc_start_call_main ./csu/../sysdeps/nptl/libc_start_call_main.h:58:16
#23 0x000075c0bba29e40 call_init ./csu/../csu/libc-start.c:128:20
#24 0x000075c0bba29e40 __libc_start_main ./csu/../csu/libc-start.c:379:5
#25 0x000062d3010afd25 _start (/home/tpopp/gisel/iree-build/llvm-project/bin/llc+0x3938d25)
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzEWU9zozgW_zTKRWUXSPw95OA4djZVySTldHftjRIgbG2EREnCSeawn31LAgwknp6emXRvVxqDJN57v_dfgmjN9oLSSxBeAYRMI5sGIATC6wvSmoNUl27oIpfl2-XKGFo3hok9NBJy-UIVNAcKK8m5fLHDhSwp1II1DTXwhZkD3HOZEw6ZphxWhHENmYCc7glnvxPDpAB4BSKP8wIuurULt1bRsi1oueQcRB7wroG36q-R1_-5R0PUnhpYEkM4eZOtgQBfQ4AQXTQAr6LAXRaNP31AAK9wd1k0ePoQTJeF05lo-hADvPIjD-AVCqPT1c4kdgb110WT2psUfVzIBi5HP3LEFkcUdFPHgc0xSPo1adQTPJ6ILY4niotj6NvR0EeLo-85OvZncUSeI2F_FsKRjYLFE0aLVbi48ReCAbyyWOyi1Np9qlOjWMPpoE9Sl_tCLEhd2v8HTU7Lu2tJKyYotMuaNnumSlAOj5KVEAQeQKgmTAAUEP0miqxkuiGmOGR-mmlZmZq8Zn6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