Commit 10a0e2a9 by Jakub Jelinek Committed by Jakub Jelinek

re PR tree-optimization/86526 (ICE in builtin_memcpy_read_str, at builtins.c:3017)

	PR tree-optimization/86526
	* builtins.c (expand_builtin_memcmp): Formatting fixes.
	(inline_expand_builtin_string_cmp): Likewise.
	(inline_string_cmp): Likewise.  Use c_readstr instead of
	builtin_memcpy_read_str.  Add unit_mode temporary.

	* gcc.c-torture/compile/pr86526.c: New test.

From-SVN: r262750
parent ce04dc3f
2018-07-16 Jakub Jelinek <jakub@redhat.com>
PR tree-optimization/86526
* builtins.c (expand_builtin_memcmp): Formatting fixes.
(inline_expand_builtin_string_cmp): Likewise.
(inline_string_cmp): Likewise. Use c_readstr instead of
builtin_memcpy_read_str. Add unit_mode temporary.
2018-07-16 Bernd Edlinger <bernd.edlinger@hotmail.de>
PR middle-end/86528
......
......@@ -6776,7 +6776,7 @@ expand_builtin_goacc_parlevel_id_size (tree exp, rtx target, int ignore)
*/
static rtx
inline_string_cmp (rtx target, tree var_str, const char* const_str,
inline_string_cmp (rtx target, tree var_str, const char *const_str,
unsigned HOST_WIDE_INT length,
int const_str_n, machine_mode mode,
bool is_memcmp)
......@@ -6789,6 +6789,8 @@ inline_string_cmp (rtx target, tree var_str, const char* const_str,
rtx result = target ? target : gen_reg_rtx (mode);
rtx_code_label *ne_label = gen_label_rtx ();
tree unit_type_node = is_memcmp ? unsigned_char_type_node : char_type_node;
scalar_int_mode unit_mode
= as_a <scalar_int_mode> TYPE_MODE (unit_type_node);
start_sequence ();
......@@ -6796,11 +6798,7 @@ inline_string_cmp (rtx target, tree var_str, const char* const_str,
{
var_rtx
= adjust_address (var_rtx_array, TYPE_MODE (unit_type_node), offset);
const_rtx
= builtin_memcpy_read_str (CONST_CAST (char *, const_str),
offset,
as_a <scalar_int_mode>
TYPE_MODE (unit_type_node));
const_rtx = c_readstr (const_str + offset, unit_mode);
rtx op0 = (const_str_n == 1) ? const_rtx : var_rtx;
rtx op1 = (const_str_n == 1) ? var_rtx : const_rtx;
......@@ -6809,8 +6807,7 @@ inline_string_cmp (rtx target, tree var_str, const char* const_str,
if (i < length - 1)
emit_cmp_and_jump_insns (result, CONST0_RTX (mode), NE, NULL_RTX,
mode, true, ne_label);
offset
+= GET_MODE_SIZE (as_a <scalar_int_mode> TYPE_MODE (unit_type_node));
offset += GET_MODE_SIZE (unit_mode);
}
emit_label (ne_label);
......
2018-07-16 Jakub Jelinek <jakub@redhat.com>
PR tree-optimization/86526
* gcc.c-torture/compile/pr86526.c: New test.
2018-07-16 Carl Love <cel@us.ibm.com>
* gcc.target/powerpc/divkc3-2.c: Add dg-require-effective-target
......
/* PR tree-optimization/86526 */
void
foo (char *x)
{
if (__builtin_memcmp (x, "\0a", 3))
__builtin_abort ();
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment