[PATCH] D128572: [LoongArch] Add codegen support for division operations

WÁNG Xuěruì via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sat Jun 25 01:39:59 PDT 2022


xen0n added a comment.

I just experimented on 3A5000 and it seems the "undefined result" is all-zeros, and unfortunately the `div.w`/`mod.w` UB when input operand is non-canonical (i.e. non-sign-extended) 32-bit is indeed present; in this case the output is all-zeros too.

So the sign-extension is indeed necessary for inputs not statically known to be `signext`. The all-zeros in case of UB is less useful than RISCV's all-ones, in terms of expected semantics (we want ideally something near "infinity"), but it's UB after all, and 0 is equally okay here.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128572



More information about the llvm-commits mailing list