rtx op1 = expand_normal (rhs1);
rtx op2 = expand_normal (rhs2);
- gcc_assert (TREE_CODE (rhs3) == INTEGER_CST);
- rtx op3 = gen_int_mode (TREE_INT_CST_LOW (rhs3), crc_mode);
+ rtx op3;
+ if (TREE_CODE (rhs3) != INTEGER_CST)
+ {
+ error ("third argument to %<crc%> builtins must be a constant");
+ op3 = const0_rtx;
+ }
+ else
+ op3 = convert_to_mode (crc_mode, expand_normal (rhs3), 0);
if (CONST_INT_P (op2))
- op2 = gen_int_mode (INTVAL (op2), crc_mode);
+ op2 = convert_to_mode (crc_mode, op2, 0);
if (fn == IFN_CRC)
expand_crc_table_based (target, op1, op2, op3, data_mode);
Returns the calculated 8-bit bit-reversed CRC using the initial CRC (8-bit),
data (8-bit) and the polynomial (8-bit).
@var{crc} is the initial CRC, @var{data} is the data and
-@var{poly} is the polynomial without leading 1.
+@var{poly} is the polynomial without leading 1. @var{poly} is required to be a compile-time constant.
Table-based or clmul-based CRC may be used for the
calculation, depending on the target architecture.
@enddefbuiltin
Returns the calculated 8-bit bit-forward CRC using the initial CRC (8-bit),
data (8-bit) and the polynomial (8-bit).
@var{crc} is the initial CRC, @var{data} is the data and
-@var{poly} is the polynomial without leading 1.
+@var{poly} is the polynomial without leading 1. @var{poly} is required to be a compile-time constant.
Table-based or clmul-based CRC may be used for the
calculation, depending on the target architecture.
@enddefbuiltin
rtx dest = expand_expr (lhs, NULL_RTX, VOIDmode, EXPAND_WRITE);
rtx crc = expand_normal (rhs1);
rtx data = expand_normal (rhs2);
- gcc_assert (TREE_CODE (rhs3) == INTEGER_CST);
- rtx polynomial = gen_rtx_CONST_INT (TYPE_MODE (result_type),
- TREE_INT_CST_LOW (rhs3));
+ rtx polynomial;
+ if (TREE_CODE (rhs3) != INTEGER_CST)
+ {
+ error ("third argument to %<crc%> builtins must be a constant");
+ polynomial = const0_rtx;
+ }
+ else
+ polynomial = convert_to_mode (TYPE_MODE (result_type), expand_normal (rhs3), 0);
/* Use target specific expansion if it exists.
Otherwise, generate table-based CRC. */
--- /dev/null
+/* { dg-do compile } */
+/* { dg-options "" } */
+
+/* PR middle-end/120709 */
+/* Make sure we don't ICE on a non-constant poly argument. */
+
+
+typedef unsigned char uint8_t;
+uint8_t crc8_data8(uint8_t crc, uint8_t data, uint8_t polynomial) {
+ return __builtin_rev_crc32_data8 (crc, data, polynomial); /* { dg-error "must be a constant" } */
+}