[PATCH] D126461: [RISCV] Extract and store new vl of vleff iff destination isn't null

Wang Pengcheng via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri May 27 01:34:47 PDT 2022


pcwang-thead added a comment.

In D126461#3541577 <https://reviews.llvm.org/D126461#3541577>, @craig.topper wrote:

> What if it isn't known to be null at compile time but gets optimized to it.

Thanks, I haven't thought it clearly and I just wanted to solve found bugs. :-)
I changed it to generate IRs to do the check. It is the same as GCC implementation now I think.
https://github.com/riscv-collab/riscv-gcc/blob/riscv-gcc-10.1-rvv-dev/gcc/config/riscv/riscv_vector.h#L289

  if (new_vl)								\
      {									\
      if (__riscv_xlen == 32)						\
        *new_vl = __builtin_riscv_vreadvlsi ();				\
      else								\
        *new_vl = __builtin_riscv_vreadvldi ();				\
      }	



> Are we trying to make passing a null pointer defined behavior for these intrinsics?

Yes, but only for vleff instructions, since it has two outputs actually. And this behavior is compatible with GCC.
If necessary, I will propose it to rvv-intrinsic-doc.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D126461/new/

https://reviews.llvm.org/D126461



More information about the cfe-commits mailing list