Issue 174601
Summary RISC-V clz uses legacy encoding
Labels new issue
Assignees
Reporter nazar-pc
    I'm using the following Rust toolchain:
```
rustc 1.94.0-nightly (8d670b93d 2025-12-31)
binary: rustc
commit-hash: 8d670b93d40737e1b320fd892c6f169ffa35e49e
commit-date: 2025-12-31
host: x86_64-unknown-linux-gnu
release: 1.94.0-nightly
LLVM version: 21.1.8
```

When compiling one of the binaries with the following target specification:
```json
{
  "arch": "riscv64",
 "code-model": "medium",
  "cpu": "generic-rv64",
 "crt-objects-fallback": "false",
  "data-layout": "e-m:e-p:64:64-i64:64-i128:128-n32:64-S64",
  "only-cdylib": true,
 "executables": false,
  "eh-frame-header": false,
 "emit-debug-gdb-scripts": false,
  "features": "+e,+m,+b,+zbc",
 "linker": "rust-lld",
  "linker-flavor": "ld.lld",
 "llvm-abiname": "lp64e",
  "llvm-target": "riscv64",
 "max-atomic-width": 64,
  "panic-strategy": "immediate-abort",
 "position-independent-executables": true,
  "relro-level": "full",
 "static-position-independent-executables": true,
 "target-pointer-width": 64,
  "relocation-model": "pie",
 "singlethread": true,
  "dynamic-linking": true,
 "default-visibility": "hidden",
  "pre-link-args": {
    "ld": [
 "-Bsymbolic"
    ]
  },
  "dll-prefix": "",
  "dll-suffix": ".contract.so",
  "env": "abundance"
}
```

I hit an instruction `0x60051513`.

`objdump` decodes it to `clz a0, a0`, but apparently it is not a legal instruction in ratified version of Zbb extension, it was used by earlier drafts.

Is there a reason for this or just an oversight?
I suspect `ctz` and `cpop` might be affected in a similar way.
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to