[llvm] [SelectionDAG] powi and ldexp libcalls deal with signed int arguments (PR #213673)

Simonas Kazlauskas via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 5 02:46:20 PDT 2026


nagisa wrote:

I found a target/test where this test *had* an expected effect in an older revision of LLVM.  The test, however was removed https://github.com/llvm/llvm-project/pull/148641 and the relevant functionality shortly afterwards.

This change backported to LLVM 20 would result in the following assembly diff for the test:

```diff
 addiu $sp, $sp, -24
 sw $ra, 20($sp)
+sll $1, $4, 16
 jal ldexpl
-andi $4, $4, 65535
+sra $4, $1, 16
 move $4, $2
 addiu $2, $zero, 0
 lw $ra, 20($sp)
 jr $ra
 addiu $sp, $sp, 24
```

I'm not sure why the target was truncating(?) the argument to 16 bits with the `andi` instruction in the first place, and maybe there is no sense in trying to make sense of this ill-formed code, but the fact that it would switch over to the sign-extended operation for such scenario is exactly the behaviour this PR intends to achieve.

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


More information about the llvm-commits mailing list