Be conservative with arithmetic jmp-function types
2017-11-29 Martin Jambor <mjambor@suse.cz> PR ipa/82808 * tree.c (expr_type_first_operand_type_p): New function. * tree.h (expr_type_first_operand_type_p): Declare it. * ipa-cp.c (ipa_get_jf_pass_through_result): Use it. testsuite/ * gcc.dg/ipa/pr82808.c: New test. From-SVN: r255256
This commit is contained in:
parent
330f2c9882
commit
daccaeb998
@ -1,3 +1,10 @@
|
|||||||
|
2017-11-29 Martin Jambor <mjambor@suse.cz>
|
||||||
|
|
||||||
|
PR ipa/82808
|
||||||
|
* tree.c (expr_type_first_operand_type_p): New function.
|
||||||
|
* tree.h (expr_type_first_operand_type_p): Declare it.
|
||||||
|
* ipa-cp.c (ipa_get_jf_pass_through_result): Use it.
|
||||||
|
|
||||||
2017-11-29 Daniel Cederman <cederman@gaisler.com>
|
2017-11-29 Daniel Cederman <cederman@gaisler.com>
|
||||||
|
|
||||||
Backport from mainline
|
Backport from mainline
|
||||||
|
26
gcc/ipa-cp.c
26
gcc/ipa-cp.c
@ -1224,20 +1224,20 @@ ipa_get_jf_pass_through_result (struct ipa_jump_func *jfunc, tree input)
|
|||||||
if (!is_gimple_ip_invariant (input))
|
if (!is_gimple_ip_invariant (input))
|
||||||
return NULL_TREE;
|
return NULL_TREE;
|
||||||
|
|
||||||
if (TREE_CODE_CLASS (ipa_get_jf_pass_through_operation (jfunc))
|
tree_code opcode = ipa_get_jf_pass_through_operation (jfunc);
|
||||||
== tcc_unary)
|
if (TREE_CODE_CLASS (opcode) == tcc_comparison)
|
||||||
res = fold_unary (ipa_get_jf_pass_through_operation (jfunc),
|
restype = boolean_type_node;
|
||||||
TREE_TYPE (input), input);
|
else if (expr_type_first_operand_type_p (opcode))
|
||||||
|
restype = TREE_TYPE (input);
|
||||||
else
|
else
|
||||||
{
|
return NULL_TREE;
|
||||||
if (TREE_CODE_CLASS (ipa_get_jf_pass_through_operation (jfunc))
|
|
||||||
== tcc_comparison)
|
if (TREE_CODE_CLASS (opcode) == tcc_unary)
|
||||||
restype = boolean_type_node;
|
res = fold_unary (opcode, restype, input);
|
||||||
else
|
else
|
||||||
restype = TREE_TYPE (input);
|
res = fold_binary (opcode, restype, input,
|
||||||
res = fold_binary (ipa_get_jf_pass_through_operation (jfunc), restype,
|
ipa_get_jf_pass_through_operand (jfunc));
|
||||||
input, ipa_get_jf_pass_through_operand (jfunc));
|
|
||||||
}
|
|
||||||
if (res && !is_gimple_ip_invariant (res))
|
if (res && !is_gimple_ip_invariant (res))
|
||||||
return NULL_TREE;
|
return NULL_TREE;
|
||||||
|
|
||||||
|
@ -1,3 +1,8 @@
|
|||||||
|
2017-11-29 Martin Jambor <mjambor@suse.cz>
|
||||||
|
|
||||||
|
PR ipa/82808
|
||||||
|
* gcc.dg/ipa/pr82808.c: New test.
|
||||||
|
|
||||||
2017-11-23 Paul Thomas <pault@gcc.gnu.org>
|
2017-11-23 Paul Thomas <pault@gcc.gnu.org>
|
||||||
|
|
||||||
Backported from trunk
|
Backported from trunk
|
||||||
|
27
gcc/testsuite/gcc.dg/ipa/pr82808.c
Normal file
27
gcc/testsuite/gcc.dg/ipa/pr82808.c
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
/* { dg-options "-O2" } */
|
||||||
|
/* { dg-do run } */
|
||||||
|
|
||||||
|
static void __attribute__((noinline))
|
||||||
|
foo (double *a, double x)
|
||||||
|
{
|
||||||
|
*a = x;
|
||||||
|
}
|
||||||
|
|
||||||
|
static double __attribute__((noinline))
|
||||||
|
f_c1 (int m, double *a)
|
||||||
|
{
|
||||||
|
foo (a, m);
|
||||||
|
return *a;
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
main (){
|
||||||
|
double data;
|
||||||
|
double ret = 0 ;
|
||||||
|
|
||||||
|
if ((ret = f_c1 (2, &data)) != 2)
|
||||||
|
{
|
||||||
|
__builtin_abort ();
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
44
gcc/tree.c
44
gcc/tree.c
@ -14515,6 +14515,50 @@ get_nonnull_args (const_tree fntype)
|
|||||||
return argmap;
|
return argmap;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Return true if an expression with CODE has to have the same result type as
|
||||||
|
its first operand. */
|
||||||
|
|
||||||
|
bool
|
||||||
|
expr_type_first_operand_type_p (tree_code code)
|
||||||
|
{
|
||||||
|
switch (code)
|
||||||
|
{
|
||||||
|
case NEGATE_EXPR:
|
||||||
|
case ABS_EXPR:
|
||||||
|
case BIT_NOT_EXPR:
|
||||||
|
case PAREN_EXPR:
|
||||||
|
case CONJ_EXPR:
|
||||||
|
|
||||||
|
case PLUS_EXPR:
|
||||||
|
case MINUS_EXPR:
|
||||||
|
case MULT_EXPR:
|
||||||
|
case TRUNC_DIV_EXPR:
|
||||||
|
case CEIL_DIV_EXPR:
|
||||||
|
case FLOOR_DIV_EXPR:
|
||||||
|
case ROUND_DIV_EXPR:
|
||||||
|
case TRUNC_MOD_EXPR:
|
||||||
|
case CEIL_MOD_EXPR:
|
||||||
|
case FLOOR_MOD_EXPR:
|
||||||
|
case ROUND_MOD_EXPR:
|
||||||
|
case RDIV_EXPR:
|
||||||
|
case EXACT_DIV_EXPR:
|
||||||
|
case MIN_EXPR:
|
||||||
|
case MAX_EXPR:
|
||||||
|
case BIT_IOR_EXPR:
|
||||||
|
case BIT_XOR_EXPR:
|
||||||
|
case BIT_AND_EXPR:
|
||||||
|
|
||||||
|
case LSHIFT_EXPR:
|
||||||
|
case RSHIFT_EXPR:
|
||||||
|
case LROTATE_EXPR:
|
||||||
|
case RROTATE_EXPR:
|
||||||
|
return true;
|
||||||
|
|
||||||
|
default:
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#if CHECKING_P
|
#if CHECKING_P
|
||||||
|
|
||||||
namespace selftest {
|
namespace selftest {
|
||||||
|
@ -5471,6 +5471,7 @@ extern void gt_pch_nx (tree &, gt_pointer_operator, void *);
|
|||||||
|
|
||||||
extern bool nonnull_arg_p (const_tree);
|
extern bool nonnull_arg_p (const_tree);
|
||||||
extern bool is_redundant_typedef (const_tree);
|
extern bool is_redundant_typedef (const_tree);
|
||||||
|
extern bool expr_type_first_operand_type_p (tree_code);
|
||||||
|
|
||||||
extern location_t
|
extern location_t
|
||||||
set_source_range (tree expr, location_t start, location_t finish);
|
set_source_range (tree expr, location_t start, location_t finish);
|
||||||
|
Loading…
Reference in New Issue
Block a user