[llvm] [LoongArch] Use div.w/mod.w to eliminate unnecessary sign-extend for sdiv/srem i32. (PR #117298)

via llvm-commits llvm-commits at lists.llvm.org
Sat Nov 23 19:04:14 PST 2024


================
@@ -44,6 +44,8 @@ enum NodeType : unsigned {
   ROTR_W,
 
   // unsigned 32-bit integer division
+  DIV_W,
+  MOD_W,
----------------
heiher wrote:

This is a split from PR #116764. [^1] It aims to control the extension mode of the input operands for `div.w`/`mod.w` based on the `div32` target feature. [^2] (On LoongArch, if the `div32` target feature is not enabled, the results of `div.w`/`mod.w` operations are unpredictable if the input operands are not sign-extended. This behavior may differ from RISC-V.

[^1]: https://github.com/llvm/llvm-project/pull/116764/files#r1849838395
[^2]: https://github.com/llvm/llvm-project/pull/116764/files#diff-47299c232403370e6e02355713cf717324051be6fbaa48257087ebdf0d46ae37R2841-R2844

https://github.com/llvm/llvm-project/pull/117298


More information about the llvm-commits mailing list