[1/2] lim/cselim: Use lhs_could_trap_p directly instead of inline
Commit Message
Instead of calling tree_could_trap_p and then testing decl/string,
we can just use lhs_could_trap_p.
This will be used by the next patch to fix `this->a` accesses.
Bootstrapped and tested on x86_64-linux-gnu.
gcc/ChangeLog:
* tree-ssa-loop-im.cc (can_sm_ref_p): Use lhs_could_trap_p.
* tree-ssa-phiopt.cc (cond_store_replacement): Likewise.
Signed-off-by: Andrea Pinski <andrew.pinski@oss.qualcomm.com>
---
gcc/tree-ssa-loop-im.cc | 12 ++----------
gcc/tree-ssa-phiopt.cc | 9 +--------
2 files changed, 3 insertions(+), 18 deletions(-)
Comments
On 9/1/26 5:57 PM, Andrea Pinski wrote:
> Instead of calling tree_could_trap_p and then testing decl/string,
> we can just use lhs_could_trap_p.
> This will be used by the next patch to fix `this->a` accesses.
>
> Bootstrapped and tested on x86_64-linux-gnu.
>
> gcc/ChangeLog:
>
> * tree-ssa-loop-im.cc (can_sm_ref_p): Use lhs_could_trap_p.
> * tree-ssa-phiopt.cc (cond_store_replacement): Likewise.
>
> Signed-off-by: Andrea Pinski <andrew.pinski@oss.qualcomm.com>
OK
jeff
@@ -3351,8 +3351,6 @@ ref_in_loop_hot_body::operator () (mem_ref_loc *loc)
static bool
can_sm_ref_p (class loop *loop, im_mem_ref *ref)
{
- tree base;
-
/* Can't hoist unanalyzable refs. */
if (!MEM_ANALYZABLE (ref))
return false;
@@ -3371,14 +3369,8 @@ can_sm_ref_p (class loop *loop, im_mem_ref *ref)
if (tree_could_throw_p (ref->mem.ref))
return false;
- /* If it can trap, it must be always executed in LOOP.
- Readonly memory locations may trap when storing to them, but
- tree_could_trap_p is a predicate for rvalues, so check that
- explicitly. */
- base = get_base_address (ref->mem.ref);
- if ((tree_could_trap_p (ref->mem.ref)
- || (DECL_P (base) && TREE_READONLY (base))
- || TREE_CODE (base) == STRING_CST)
+ /* If the store can trap, it must be always executed in LOOP. */
+ if (lhs_could_trap_p (ref->mem.ref)
/* ??? We can at least use false here, allowing loads? We
are forcing conditional stores if the ref is not always
stored to later anyway. So this would only guard
@@ -3289,15 +3289,8 @@ cond_store_replacement (basic_block middle_bb, basic_block join_bb, edge e0,
/* If LHS is an access to a local variable without address-taken
(or when we allow data races) and known not to trap, we could
always safely move down the store. */
- tree base;
if (ref_can_have_store_data_races (lhs)
- || tree_could_trap_p (lhs)
- /* tree_could_trap_p is a predicate for rvalues, so check
- for readonly memory explicitly. */
- || ((base = get_base_address (lhs))
- && ((DECL_P (base)
- && TREE_READONLY (base))
- || TREE_CODE (base) == STRING_CST)))
+ || lhs_could_trap_p (lhs))
return false;
}