]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
RISC-V: Fix warning in riscv.md
authorFrom: Juzhe-Zhong <juzhe.zhong@rivai.ai>
Tue, 30 May 2023 02:16:09 +0000 (10:16 +0800)
committerPan Li <pan2.li@intel.com>
Tue, 30 May 2023 02:16:09 +0000 (10:16 +0800)
Notice there is warning:
../../../riscv-gcc/gcc/config/riscv/riscv.md:1356:32: warning:
comparison between signed and unsigned integer expressions
[-Wsign-compare]
       if (INTVAL (operands[2]) == GET_MODE_MASK (HImode))
../../../riscv-gcc/gcc/config/riscv/riscv.md:1358:37: warning:
comparison between signed and unsigned integer expressions
[-Wsign-compare]
       else if (INTVAL (operands[2]) == GET_MODE_MASK (SImode))
../../../riscv-gcc/gcc/config/riscv/riscv.md: In function â€˜rtx_def*
gen_anddi3(rtx, rtx, rtx)’:
../../../riscv-gcc/gcc/config/riscv/riscv.md:1356:32: warning:
comparison between signed and unsigned integer expressions
[-Wsign-compare]
       if (INTVAL (operands[2]) == GET_MODE_MASK (HImode))
../../../riscv-gcc/gcc/config/riscv/riscv.md:1358:37: warning:
comparison between signed and unsigned integer expressions
[-Wsign-compare]
       else if (INTVAL (operands[2]) == GET_MODE_MASK (SImode))

Add unsigned conversion to fix this warning.

Signed-off-by: Juzhe-Zhong <juzhe.zhong@rivai.ai>
gcc/ChangeLog:

* config/riscv/riscv.md: Fix signed and unsigned comparison
warning.

gcc/config/riscv/riscv.md

index aba203318a73ddd99f94c6b54cedaa49065a2f45..f545874edc13f881174d7d4acae4fd02e569e425 100644 (file)
   if (CONST_INT_P (operands[2]))
     {
       enum machine_mode tmode = VOIDmode;
-      if (INTVAL (operands[2]) == GET_MODE_MASK (HImode))
+      if (UINTVAL (operands[2]) == GET_MODE_MASK (HImode))
        tmode = HImode;
-      else if (INTVAL (operands[2]) == GET_MODE_MASK (SImode))
+      else if (UINTVAL (operands[2]) == GET_MODE_MASK (SImode))
        tmode = SImode;
 
       if (tmode != VOIDmode)