<div dir="ltr">I think this might work<br><br>#include <stdio.h><br>#include <riscv_vector.h><br><br>#define N 5<br><br>int main(int argc, char **argv)<br>{<br>signed char A[N] = {1, 2, 3, 4, 5};<br>vint8m1_t B = vle8_v_i8m1(A, N);<br>vbool8_t C = vmseq_vx_i8m1_b8(B, 3, N);<br><br>long i;<br>while ((i = vfirst_m_b8(C, N)) >= 0) {<br>printf("INDEX:%ld", i);<br>C = vmandnot_mm_b8(C, vmsof_m_b8(C, N), N);<br>}<br>return 0;<br>}<div><br></div><br clear="all"><div><div dir="ltr" class="gmail_signature" data-smartmail="gmail_signature">~Craig</div></div><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, Jul 9, 2021 at 7:33 PM Shao-Ce Sun <<a href="mailto:llvm@foxmail.com">llvm@foxmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div>Thanks for your help, and here is the code:</div><div><br></div><div><div>#include <stdio.h></div><div>#include <riscv_vector.h></div><div><br></div><div>#define N 5</div><div><br></div><div>int main(int argc, char **argv)</div><div>{</div><div> signed char A[N] = {1, 2, 3, 4, 5};</div><div> vint8m1_t B = vle8_v_i8m1(A, N);</div><div> vbool8_t C = vmseq_vx_i8m1_b8(B, 3, N);</div><div> int i;</div><div> for (i = 0; i < N; ++i)</div><div> {</div><div> if (C[i])</div><div> printf("INDEX:%d", i);</div><div> }</div><div>}</div></div><div><br></div><div><br></div><div><div><br></div><div style="font-size:12px;font-family:"Arial Narrow";padding:2px 0px">------------------ Original ------------------</div><div style="font-size:12px;background:rgb(239,239,239);padding:8px"><div><b>From:</b> "Craig Topper" <<a href="mailto:craig.topper@gmail.com" target="_blank">craig.topper@gmail.com</a>>;</div><div><b>Date:</b> Fri, Jul 9, 2021 11:41 AM</div><div><b>To:</b> "Shao-Ce Sun"<<a href="mailto:llvm@foxmail.com" target="_blank">llvm@foxmail.com</a>>;</div><div><b>Cc:</b> "via llvm-dev"<<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>>;</div><div><b>Subject:</b> Re: [llvm-dev] [RISC-V V] How to read each bit of vbool8_t individually</div></div><div><br></div><div dir="ltr"><div>There aren't really any instructions for doing this in the ISA. Solutions I can think of are rounding vl to the next multiple of 8 and storing it to a uint8_t using vse8. Then reading it back by looping over the array and looking at all 8 bits of each uint8_t. Or you could use vmerge to turn into a vuint8m1_t vector of 1 and 0.</div><div><br></div><div>Perhaps if you shared your use case I might be able to come up with something else.</div><br clear="all"><div><div dir="ltr">~Craig</div></div><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, Jul 8, 2021 at 7:23 PM Shao-Ce Sun via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div><div>Hi All,</div><div> I have a question about RISC-V V, that is how to read each bit of vbool8_t individually, for example:</div><div> vbool8_t A;</div><div> bool B[8] = A;</div><div style="text-align:right">Thanks!</div></div>_______________________________________________<br>
LLVM Developers mailing list<br>
<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a><br>
<a href="https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer" target="_blank">https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a><br>
</blockquote></div></div></blockquote></div>