[llvm] [MIPS] Sign-extend subwords when expanding atomic max/min (PR #89246)

YunQiang Su via llvm-commits llvm-commits at lists.llvm.org
Fri Apr 19 00:10:56 PDT 2024


================
@@ -1118,6 +1118,8 @@ define i16 @test_max_16(ptr nocapture %ptr, i16 signext %val) {
 ; MIPSEL-NEXT:    srav $7, $7, $10
 ; MIPSEL-NEXT:    seh $2, $2
 ; MIPSEL-NEXT:    seh $7, $7
+; MIPSEL-NEXT:    sllv $2, $2, $10
----------------
wzssyqa wrote:

And `sllv` here may make the result incorrect.
The return value should be a signed int16, while with `sllv` it will be (`sign int16`)<<$10.
Note, $10 here contains the offset of a int16 in the a word, it may be `0` or `16`.

I guess the reason we do it is that we have only `ll`, while no `llb/llh`.

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


More information about the llvm-commits mailing list