Commit c875d46f by Jakub Jelinek Committed by Jakub Jelinek

re PR target/88905 (ICE: in decompose, at rtl.h:2253 with -mabm and __builtin_popcountll)

	PR target/88905
	* optabs.c (add_equal_note): Add op0_mode argument, use it instead of
	GET_MODE (op0).
	(expand_binop_directly, expand_doubleword_clz,
	expand_doubleword_popcount, expand_ctz, expand_ffs,
	expand_unop_direct, maybe_emit_unop_insn): Adjust callers.

	* gcc.dg/pr88905.c: New test.

From-SVN: r268139
parent c4814f99
2019-01-22 Jakub Jelinek <jakub@redhat.com> 2019-01-22 Jakub Jelinek <jakub@redhat.com>
PR target/88905
* optabs.c (add_equal_note): Add op0_mode argument, use it instead of
GET_MODE (op0).
(expand_binop_directly, expand_doubleword_clz,
expand_doubleword_popcount, expand_ctz, expand_ffs,
expand_unop_direct, maybe_emit_unop_insn): Adjust callers.
PR rtl-optimization/49429 PR rtl-optimization/49429
PR target/49454 PR target/49454
PR rtl-optimization/86334 PR rtl-optimization/86334
......
...@@ -55,7 +55,7 @@ void debug_optab_libfuncs (void); ...@@ -55,7 +55,7 @@ void debug_optab_libfuncs (void);
/* Add a REG_EQUAL note to the last insn in INSNS. TARGET is being set to /* Add a REG_EQUAL note to the last insn in INSNS. TARGET is being set to
the result of operation CODE applied to OP0 (and OP1 if it is a binary the result of operation CODE applied to OP0 (and OP1 if it is a binary
operation). operation). OP0_MODE is OP0's mode.
If the last insn does not set TARGET, don't do anything, but return 1. If the last insn does not set TARGET, don't do anything, but return 1.
...@@ -64,7 +64,8 @@ void debug_optab_libfuncs (void); ...@@ -64,7 +64,8 @@ void debug_optab_libfuncs (void);
try again, ensuring that TARGET is not one of the operands. */ try again, ensuring that TARGET is not one of the operands. */
static int static int
add_equal_note (rtx_insn *insns, rtx target, enum rtx_code code, rtx op0, rtx op1) add_equal_note (rtx_insn *insns, rtx target, enum rtx_code code, rtx op0,
rtx op1, machine_mode op0_mode)
{ {
rtx_insn *last_insn; rtx_insn *last_insn;
rtx set; rtx set;
...@@ -136,16 +137,16 @@ add_equal_note (rtx_insn *insns, rtx target, enum rtx_code code, rtx op0, rtx op ...@@ -136,16 +137,16 @@ add_equal_note (rtx_insn *insns, rtx target, enum rtx_code code, rtx op0, rtx op
case POPCOUNT: case POPCOUNT:
case PARITY: case PARITY:
case BSWAP: case BSWAP:
if (GET_MODE (op0) != VOIDmode && GET_MODE (target) != GET_MODE (op0)) if (op0_mode != VOIDmode && GET_MODE (target) != op0_mode)
{ {
note = gen_rtx_fmt_e (code, GET_MODE (op0), copy_rtx (op0)); note = gen_rtx_fmt_e (code, op0_mode, copy_rtx (op0));
if (GET_MODE_UNIT_SIZE (GET_MODE (op0)) if (GET_MODE_UNIT_SIZE (op0_mode)
> GET_MODE_UNIT_SIZE (GET_MODE (target))) > GET_MODE_UNIT_SIZE (GET_MODE (target)))
note = simplify_gen_unary (TRUNCATE, GET_MODE (target), note = simplify_gen_unary (TRUNCATE, GET_MODE (target),
note, GET_MODE (op0)); note, op0_mode);
else else
note = simplify_gen_unary (ZERO_EXTEND, GET_MODE (target), note = simplify_gen_unary (ZERO_EXTEND, GET_MODE (target),
note, GET_MODE (op0)); note, op0_mode);
break; break;
} }
/* FALLTHRU */ /* FALLTHRU */
...@@ -1127,7 +1128,7 @@ expand_binop_directly (enum insn_code icode, machine_mode mode, optab binoptab, ...@@ -1127,7 +1128,7 @@ expand_binop_directly (enum insn_code icode, machine_mode mode, optab binoptab,
if (INSN_P (pat) && NEXT_INSN (pat) != NULL_RTX if (INSN_P (pat) && NEXT_INSN (pat) != NULL_RTX
&& ! add_equal_note (pat, ops[0].value, && ! add_equal_note (pat, ops[0].value,
optab_to_code (binoptab), optab_to_code (binoptab),
ops[1].value, ops[2].value)) ops[1].value, ops[2].value, mode0))
{ {
delete_insns_since (last); delete_insns_since (last);
return expand_binop (mode, binoptab, op0, op1, NULL_RTX, return expand_binop (mode, binoptab, op0, op1, NULL_RTX,
...@@ -2298,7 +2299,7 @@ expand_doubleword_clz (scalar_int_mode mode, rtx op0, rtx target) ...@@ -2298,7 +2299,7 @@ expand_doubleword_clz (scalar_int_mode mode, rtx op0, rtx target)
seq = get_insns (); seq = get_insns ();
end_sequence (); end_sequence ();
add_equal_note (seq, target, CLZ, xop0, 0); add_equal_note (seq, target, CLZ, xop0, NULL_RTX, mode);
emit_insn (seq); emit_insn (seq);
return target; return target;
...@@ -2340,7 +2341,7 @@ expand_doubleword_popcount (scalar_int_mode mode, rtx op0, rtx target) ...@@ -2340,7 +2341,7 @@ expand_doubleword_popcount (scalar_int_mode mode, rtx op0, rtx target)
seq = get_insns (); seq = get_insns ();
end_sequence (); end_sequence ();
add_equal_note (seq, t, POPCOUNT, op0, 0); add_equal_note (seq, t, POPCOUNT, op0, NULL_RTX, mode);
emit_insn (seq); emit_insn (seq);
return t; return t;
} }
...@@ -2511,7 +2512,7 @@ expand_ctz (scalar_int_mode mode, rtx op0, rtx target) ...@@ -2511,7 +2512,7 @@ expand_ctz (scalar_int_mode mode, rtx op0, rtx target)
seq = get_insns (); seq = get_insns ();
end_sequence (); end_sequence ();
add_equal_note (seq, temp, CTZ, op0, 0); add_equal_note (seq, temp, CTZ, op0, NULL_RTX, mode);
emit_insn (seq); emit_insn (seq);
return temp; return temp;
} }
...@@ -2589,7 +2590,7 @@ expand_ffs (scalar_int_mode mode, rtx op0, rtx target) ...@@ -2589,7 +2590,7 @@ expand_ffs (scalar_int_mode mode, rtx op0, rtx target)
seq = get_insns (); seq = get_insns ();
end_sequence (); end_sequence ();
add_equal_note (seq, temp, FFS, op0, 0); add_equal_note (seq, temp, FFS, op0, NULL_RTX, mode);
emit_insn (seq); emit_insn (seq);
return temp; return temp;
...@@ -2736,7 +2737,7 @@ expand_unop_direct (machine_mode mode, optab unoptab, rtx op0, rtx target, ...@@ -2736,7 +2737,7 @@ expand_unop_direct (machine_mode mode, optab unoptab, rtx op0, rtx target,
if (INSN_P (pat) && NEXT_INSN (pat) != NULL_RTX if (INSN_P (pat) && NEXT_INSN (pat) != NULL_RTX
&& ! add_equal_note (pat, ops[0].value, && ! add_equal_note (pat, ops[0].value,
optab_to_code (unoptab), optab_to_code (unoptab),
ops[1].value, NULL_RTX)) ops[1].value, NULL_RTX, mode))
{ {
delete_insns_since (last); delete_insns_since (last);
return expand_unop (mode, unoptab, op0, NULL_RTX, unsignedp); return expand_unop (mode, unoptab, op0, NULL_RTX, unsignedp);
...@@ -3588,7 +3589,8 @@ maybe_emit_unop_insn (enum insn_code icode, rtx target, rtx op0, ...@@ -3588,7 +3589,8 @@ maybe_emit_unop_insn (enum insn_code icode, rtx target, rtx op0,
if (INSN_P (pat) && NEXT_INSN (pat) != NULL_RTX if (INSN_P (pat) && NEXT_INSN (pat) != NULL_RTX
&& code != UNKNOWN) && code != UNKNOWN)
add_equal_note (pat, ops[0].value, code, ops[1].value, NULL_RTX); add_equal_note (pat, ops[0].value, code, ops[1].value, NULL_RTX,
GET_MODE (op0));
emit_insn (pat); emit_insn (pat);
......
2019-01-22 Jakub Jelinek <jakub@redhat.com> 2019-01-22 Jakub Jelinek <jakub@redhat.com>
PR target/88905
* gcc.dg/pr88905.c: New test.
PR rtl-optimization/49429 PR rtl-optimization/49429
PR target/49454 PR target/49454
PR rtl-optimization/86334 PR rtl-optimization/86334
......
/* PR target/88905 */
/* { dg-do compile } */
/* { dg-options "-Og -fno-tree-ccp" } */
/* { dg-additional-options "-mabm" { target { i?86-*-* x86_64-*-* } } } */
int a, b, c;
extern void baz (int);
static inline int
bar (unsigned u)
{
int i = __builtin_popcountll (-(unsigned long long) u);
baz (i & c);
return a + b + c;
}
void
foo (void)
{
bar (2376498292ULL);
}
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