Hi, I have noticed that ivopts build MEM_REF (NOP_EXPR (address)) where NOP_EXPR converts one pointer type to another. Later it tries to expand it that on strict alignment targets punt on determining the alignment and winds expensive memory reference.
It seems to make no sense to have NOP_EXPR here, but in addition I think we want to somehow preserve alignment from original MEM_REF? Honza * tree-ssa-lop-ivopts.c (get_computation_cost_at): strip nops before building mem ref diff --git a/gcc/tree-ssa-loop-ivopts.c b/gcc/tree-ssa-loop-ivopts.c index 62ba71b..bd92031 100644 --- a/gcc/tree-ssa-loop-ivopts.c +++ b/gcc/tree-ssa-loop-ivopts.c @@ -5058,7 +5058,10 @@ fallback: return infinite_cost; if (address_p) - comp = build_simple_mem_ref (comp); + { + STRIP_NOPS (comp); + comp = build_simple_mem_ref (comp); + } cost = comp_cost (computation_cost (comp, speed), 0);