I’d like to apologize in advance if the question seems dumb, but I’ve never specified a DAG pattern for an instruction a don’t know how it looks in LLVM.
My target has an instruction which is similar to X86 horizontal add. The instruction, let’s call is sumreduce, sums up all the elements in a vector and stores a result in GPR. What I’m trying to do is to replace a specific DAG pattern (it is given below) with this instruction (DAG node).
Here is the pattern I need to replace:
r0 r1
\ /
add r2
\ /
add r3
\ /
add
r4
with
r4 = sumreduce r0 r1 r2 r3
For now assume that the vector has 4 elements in it and all of them are i32.
I would appreciate any pointers on how to do it. If someone could point me to an example code that converts a DAG pattern to a DAG node I would greatly appreciate it.