Commit f9f248c8 by Jakub Jelinek Committed by Jakub Jelinek

re PR rtl-optimization/88563 (wrong code with -O2 -fno-code-hoisting…

re PR rtl-optimization/88563 (wrong code with -O2 -fno-code-hoisting -fno-tree-ccp -fno-tree-dominator-opts -fno-tree-forwprop -fno-tree-fre -fno-tree-pre -fno-tree-vrp)

	PR rtl-optimization/88563
	* expr.c (expand_expr_real_2) <case WIDEN_MULT_EXPR>: Swap innermode
	and mode arguments to convert_modes.  Likewise swap mode and word_mode
	arguments.  Handle both arguments with VOIDmode before convert_modes
	of one of them.  Formatting fixes.

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

From-SVN: r267326
parent 247c45b2
2018-12-21 Jakub Jelinek <jakub@redhat.com>
PR rtl-optimization/88563
* expr.c (expand_expr_real_2) <case WIDEN_MULT_EXPR>: Swap innermode
and mode arguments to convert_modes. Likewise swap mode and word_mode
arguments. Handle both arguments with VOIDmode before convert_modes
of one of them. Formatting fixes.
2018-12-21 Uros Bizjak <ubizjak@gmail.com> 2018-12-21 Uros Bizjak <ubizjak@gmail.com>
PR target/88556 PR target/88556
...@@ -8775,8 +8775,8 @@ expand_expr_real_2 (sepops ops, rtx target, machine_mode tmode, ...@@ -8775,8 +8775,8 @@ expand_expr_real_2 (sepops ops, rtx target, machine_mode tmode,
!= INTEGER_CST check. Handle it. */ != INTEGER_CST check. Handle it. */
if (GET_MODE (op0) == VOIDmode && GET_MODE (op1) == VOIDmode) if (GET_MODE (op0) == VOIDmode && GET_MODE (op1) == VOIDmode)
{ {
op0 = convert_modes (innermode, mode, op0, true); op0 = convert_modes (mode, innermode, op0, true);
op1 = convert_modes (innermode, mode, op1, false); op1 = convert_modes (mode, innermode, op1, false);
return REDUCE_BIT_FIELD (expand_mult (mode, op0, op1, return REDUCE_BIT_FIELD (expand_mult (mode, op0, op1,
target, unsignedp)); target, unsignedp));
} }
...@@ -8807,9 +8807,9 @@ expand_expr_real_2 (sepops ops, rtx target, machine_mode tmode, ...@@ -8807,9 +8807,9 @@ expand_expr_real_2 (sepops ops, rtx target, machine_mode tmode,
if (GET_MODE (op0) == VOIDmode && GET_MODE (op1) == VOIDmode) if (GET_MODE (op0) == VOIDmode && GET_MODE (op1) == VOIDmode)
{ {
widen_mult_const: widen_mult_const:
op0 = convert_modes (innermode, mode, op0, zextend_p); op0 = convert_modes (mode, innermode, op0, zextend_p);
op1 op1
= convert_modes (innermode, mode, op1, = convert_modes (mode, innermode, op1,
TYPE_UNSIGNED (TREE_TYPE (treeop1))); TYPE_UNSIGNED (TREE_TYPE (treeop1)));
return REDUCE_BIT_FIELD (expand_mult (mode, op0, op1, return REDUCE_BIT_FIELD (expand_mult (mode, op0, op1,
target, target,
...@@ -8825,16 +8825,14 @@ expand_expr_real_2 (sepops ops, rtx target, machine_mode tmode, ...@@ -8825,16 +8825,14 @@ expand_expr_real_2 (sepops ops, rtx target, machine_mode tmode,
{ {
rtx htem, hipart; rtx htem, hipart;
op0 = expand_normal (treeop0); op0 = expand_normal (treeop0);
if (TREE_CODE (treeop1) == INTEGER_CST)
op1 = convert_modes (word_mode, mode,
expand_normal (treeop1),
TYPE_UNSIGNED (TREE_TYPE (treeop1)));
else
op1 = expand_normal (treeop1); op1 = expand_normal (treeop1);
/* op0 and op1 might still be constant, despite the above /* op0 and op1 might be constants, despite the above
!= INTEGER_CST check. Handle it. */ != INTEGER_CST check. Handle it. */
if (GET_MODE (op0) == VOIDmode && GET_MODE (op1) == VOIDmode) if (GET_MODE (op0) == VOIDmode && GET_MODE (op1) == VOIDmode)
goto widen_mult_const; goto widen_mult_const;
if (TREE_CODE (treeop1) == INTEGER_CST)
op1 = convert_modes (mode, word_mode, op1,
TYPE_UNSIGNED (TREE_TYPE (treeop1)));
temp = expand_binop (mode, other_optab, op0, op1, target, temp = expand_binop (mode, other_optab, op0, op1, target,
unsignedp, OPTAB_LIB_WIDEN); unsignedp, OPTAB_LIB_WIDEN);
hipart = gen_highpart (word_mode, temp); hipart = gen_highpart (word_mode, temp);
......
2018-12-21 Jakub Jelinek <jakub@redhat.com> 2018-12-21 Jakub Jelinek <jakub@redhat.com>
PR rtl-optimization/88563
* gcc.dg/pr88563.c: New test.
PR c++/87125 PR c++/87125
* g++.dg/cpp0x/pr87125.C: New test. * g++.dg/cpp0x/pr87125.C: New test.
......
/* PR rtl-optimization/88563 */
/* { dg-do run { target int128 } } */
/* { dg-options "-O2 -fno-code-hoisting -fno-tree-ccp -fno-tree-dominator-opts -fno-tree-forwprop -fno-tree-fre -fno-tree-pre -fno-tree-vrp" } */
int
main ()
{
#if __SIZEOF_LONG_LONG__ == 8 && __SIZEOF_INT128__ == 16 && __CHAR_BIT__ == 8
unsigned __int128 a = 5;
__builtin_mul_overflow (0xffffffffffffffffULL, (unsigned long long) a, &a);
if (a != ((unsigned __int128)4 << 64 | 0xfffffffffffffffb))
__builtin_abort ();
#endif
return 0;
}
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