This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [patch] missing COND_EXPR case in walk_stmt_load_store_addr_ops


> Hm, in the COND_EXPR the first operand could be a plain SSA_NAME
> or an ADDR_EXPR as well, not only a comparison. ?So you need to
> check if TREE_CODE_CLASS is tcc_comparison before recursing
> into its operands and handle ADDR_EXPR there, too.

Good point.  Will fix that - and work on the test case as well.

   Zbigniew

>> Index: gcc/gimple.c
>> ===================================================================
>> --- gcc/gimple.c ? ? ? ?(revision 163224)
>> +++ gcc/gimple.c ? ? ? ?(working copy)
>> @@ -4746,6 +4746,45 @@
>> ? return NULL_TREE;
>> ?}
>>
>> +
>> +/* For an assignment STMT which contains a selection expression on the RHS,
>> + ? i.e.,
>> +
>> + ? ? lhs = [cond_expr] a RELOP b ? x : y;
>> +
>> + ? search the entire selection expression for occurrences of ADDR_EXPR, and
>> + ? if found, apply VISIT_ADDR callback on STMT, the corresponding operand
>> + ? of ADDR_EXPR and DATA. ?Return TRUE if any of the callback invocations
>> + ? returned TRUE. ?*/
>> +
>> +static inline bool
>> +stmt_visit_select_addr_ops (gimple stmt, tree select_expr, void *data,
>> + ? ? ? ? ? ? ? ? ? ? ? ? ? bool (*visit_addr)(gimple, tree, void *))
>> +{
>> + ?bool ret = false;
>> + ?tree condop1, condop2;
>> + ?tree trueval, falseval;
>> +
>> + ?condop1 = TREE_OPERAND (TREE_OPERAND (select_expr, 0), 0);
>> + ?if (TREE_CODE (condop1) == ADDR_EXPR)
>> + ? ?ret |= visit_addr (stmt, TREE_OPERAND (condop1, 0), data);
>> +
>> + ?condop2 = TREE_OPERAND (TREE_OPERAND (select_expr, 0), 1);
>> + ?if (TREE_CODE (condop2) == ADDR_EXPR)
>> + ? ?ret |= visit_addr (stmt, TREE_OPERAND (condop2, 0), data);
>> +
>> + ?trueval = TREE_OPERAND (select_expr, 1);
>> + ?if (TREE_CODE (trueval) == ADDR_EXPR)
>> + ? ?ret |= visit_addr (stmt, TREE_OPERAND (trueval, 0), data);
>> +
>> + ?falseval = TREE_OPERAND (select_expr, 2);
>> + ?if (TREE_CODE (falseval) == ADDR_EXPR)
>> + ? ?ret |= visit_addr (stmt, TREE_OPERAND (falseval, 0), data);
>> +
>> + ?return ret;
>> +}
>> +
>> +
>> ?/* For the statement STMT call the callbacks VISIT_LOAD, VISIT_STORE and
>> ? ?VISIT_ADDR if non-NULL on loads, store and address-taken operands
>> ? ?passing the STMT, the base of the operand and DATA to it. ?The base
>> @@ -4761,6 +4800,7 @@
>> ?{
>> ? bool ret = false;
>> ? unsigned i;
>> +
>> ? if (gimple_assign_single_p (stmt))
>> ? ? {
>> ? ? ? tree lhs, rhs;
>> @@ -4785,6 +4825,9 @@
>> ? ? ? ? ? ? ? ? ? && TREE_CODE (OBJ_TYPE_REF_OBJECT (rhs)) == ADDR_EXPR)
>> ? ? ? ? ? ?ret |= visit_addr (stmt, TREE_OPERAND (OBJ_TYPE_REF_OBJECT (rhs),
>> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? 0), data);
>> + ? ? ? ? else if (TREE_CODE (rhs) == COND_EXPR)
>> + ? ? ? ? ? ret |= stmt_visit_select_addr_ops (stmt, rhs, data, visit_addr);
>> +
>> ? ? ? ? ? lhs = gimple_assign_lhs (stmt);
>> ? ? ? ? ?if (TREE_CODE (lhs) == TARGET_MEM_REF
>> ? ? ? ? ? ? ? && TMR_BASE (lhs) != NULL_TREE
>>
>>
>>


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]