[riscv] Fix build due to INT16_MAX issue
authorKyrylo Tkachov <kyrylo.tkachov@arm.com>
Wed, 8 Feb 2017 09:14:39 +0000 (09:14 +0000)
committerKyrylo Tkachov <ktkachov@gcc.gnu.org>
Wed, 8 Feb 2017 09:14:39 +0000 (09:14 +0000)
* config/riscv/riscv.c (riscv_build_integer_1): Avoid use of INT16_MAX.

From-SVN: r245272

gcc/ChangeLog
gcc/config/riscv/riscv.c

index 1b518e6..bb1e7e9 100644 (file)
@@ -1,3 +1,7 @@
+2016-02-08  Kyrylo Tkachov  <kyrylo.tkachov@arm.com>
+
+       * config/riscv/riscv.c (riscv_build_integer_1): Avoid use of INT16_MAX.
+
 2017-02-08  Richard Biener  <rguenther@suse.de>
 
        PR tree-optimization/71824
index 834651f..89567f7 100644 (file)
@@ -356,7 +356,9 @@ riscv_build_integer_1 (struct riscv_integer_op codes[RISCV_MAX_INTEGER_OPS],
   /* End with ADDI.  When constructing HImode constants, do not generate any
      intermediate value that is not itself a valid HImode constant.  The
      XORI case below will handle those remaining HImode constants.  */
-  if (low_part != 0 && (mode != HImode || value - low_part <= INT16_MAX))
+  if (low_part != 0
+      && (mode != HImode
+         || value - low_part <= ((1 << (GET_MODE_BITSIZE (HImode) - 1)) - 1)))
     {
       alt_cost = 1 + riscv_build_integer_1 (alt_codes, value - low_part, mode);
       if (alt_cost < cost)