Search code examples
gccriscvinstruction-set

How to compile for riscv zicond extension in gcc?


I wanted to use zicond extension for risc-v architecture. I read those messages. I couldn't understand how to compile for zicond extension. I tried in godbolt 1 and godbolt 2 with different march flags. However, both didn't produce a conditional operation.

Could you help me to get a GCC which is developed for zicond? (I have done it for llvm(clang), but I wonder for GCC )


Solution

  • GCC13.2 isn't new enough. 14.0.0 will be, but isn't released yet.

    gcc (trunk 14.0.0 20231022) on Godbolt does use czero.eqz when you compile with -march=rv64gc_zicond or -march=rv64gc_zicond1p0 (https://godbolt.org/z/xod75bTEK).

    Clang still needs -menable-experimental-extensions and the option with a version number (1p0)

    Future readers: see RISCV branchless coding for more about the current state of Zicond and other stuff that was going to be part of extension B before that got split up.