Constant integers with MSB set have to be represented as corresponding
signed integers. Use gen_int_mode to emit them in the correct way.
PR middle-end/118288
gcc/ChangeLog:
* builtins.cc (expand_builtin_crc_table_based):
Use gen_int_mode to emit constant integers with MSB set.
gcc/testsuite/ChangeLog:
* gcc.dg/pr118288.c: New test.
gcc_assert (TREE_CODE (rhs3) == INTEGER_CST);
rtx op3 = gen_int_mode (TREE_INT_CST_LOW (rhs3), crc_mode);
+ if (CONST_INT_P (op2))
+ op2 = gen_int_mode (INTVAL (op2), crc_mode);
+
if (fn == IFN_CRC)
expand_crc_table_based (target, op1, op2, op3, data_mode);
else
--- /dev/null
+/* PR middle-end 118288 */
+/* { dg-do compile } */
+/* { dg-options "-O2" } */
+
+signed char crc8_data8 ()
+{
+ return __builtin_crc8_data8 ('a', 0xff, 0x12);
+}