aboutsummaryrefslogtreecommitdiff
path: root/gcc/builtins.cc
diff options
context:
space:
mode:
authorUros Bizjak <ubizjak@gmail.com>2025-02-16 22:01:27 +0100
committerUros Bizjak <ubizjak@gmail.com>2025-02-17 20:47:53 +0100
commit09684c53bca7dad47d36875b359e83551f9015fd (patch)
treea273785e5cbc2e45973dfb59dd0c84d0d43516e8 /gcc/builtins.cc
parent1787119229abca0c78f9c902eeb7c88efed37ce0 (diff)
downloadgcc-09684c53bca7dad47d36875b359e83551f9015fd.zip
gcc-09684c53bca7dad47d36875b359e83551f9015fd.tar.gz
gcc-09684c53bca7dad47d36875b359e83551f9015fd.tar.bz2
middle-end: Fixup constant integers when expanding __builtin_crc [PR118288]
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.
Diffstat (limited to 'gcc/builtins.cc')
-rw-r--r--gcc/builtins.cc3
1 files changed, 3 insertions, 0 deletions
diff --git a/gcc/builtins.cc b/gcc/builtins.cc
index 468bd65..c884103 100644
--- a/gcc/builtins.cc
+++ b/gcc/builtins.cc
@@ -7803,6 +7803,9 @@ expand_builtin_crc_table_based (internal_fn fn, scalar_mode crc_mode,
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