* [PATCH] Fix PR71893
@ 2016-07-15 13:20 Richard Biener
2016-07-18 7:03 ` Thomas Schwinge
0 siblings, 1 reply; 2+ messages in thread
From: Richard Biener @ 2016-07-15 13:20 UTC (permalink / raw)
To: gcc-patches
This PR shows that array_ref_element_size may apply spurious casts which
in turn end up confusing VN/PRE.
Fixed as follows, bootstrapped on x86_64-unknown-linux-gnu, testing in
progress.
Richard.
2016-07-15 Richard Biener <rguenther@suse.de>
PR tree-optimization/71893
* tree-ssa-pre.c (create_component_ref_by_pieces_1): Compensate
for sizetype cast added by array_ref_element_size.
* tree-ssa-sccvn.c (copy_reference_ops_from_ref): Likewise.
Index: gcc/tree-ssa-pre.c
===================================================================
*** gcc/tree-ssa-pre.c (revision 238370)
--- gcc/tree-ssa-pre.c (working copy)
*************** create_component_ref_by_pieces_1 (basic_
*** 2576,2581 ****
--- 2587,2595 ----
{
genop3 = size_binop (EXACT_DIV_EXPR, genop3,
size_int (TYPE_ALIGN_UNIT (elmt_type)));
+ /* We may have a useless conversion added by
+ array_ref_element_size via copy_reference_opts_from_ref. */
+ STRIP_USELESS_TYPE_CONVERSION (genop3);
genop3 = find_or_generate_expression (block, genop3, stmts);
if (!genop3)
return NULL_TREE;
Index: gcc/tree-ssa-sccvn.c
===================================================================
*** gcc/tree-ssa-sccvn.c (revision 238370)
--- gcc/tree-ssa-sccvn.c (working copy)
*************** copy_reference_ops_from_ref (tree ref, v
*** 810,815 ****
--- 810,818 ----
/* Always record lower bounds and element size. */
temp.op1 = array_ref_low_bound (ref);
temp.op2 = array_ref_element_size (ref);
+ /* array_ref_element_size forces the result to sizetype
+ even if that is the same as bitsizetype. */
+ STRIP_USELESS_TYPE_CONVERSION (temp.op2);
if (TREE_CODE (temp.op0) == INTEGER_CST
&& TREE_CODE (temp.op1) == INTEGER_CST
&& TREE_CODE (temp.op2) == INTEGER_CST)
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] Fix PR71893
2016-07-15 13:20 [PATCH] Fix PR71893 Richard Biener
@ 2016-07-18 7:03 ` Thomas Schwinge
0 siblings, 0 replies; 2+ messages in thread
From: Thomas Schwinge @ 2016-07-18 7:03 UTC (permalink / raw)
To: Richard Biener; +Cc: dcb314, gcc-patches
[-- Attachment #1: Type: text/plain, Size: 2117 bytes --]
Hi!
On Fri, 15 Jul 2016 15:19:59 +0200 (CEST), Richard Biener <rguenther@suse.de> wrote:
> This PR shows that
(There is also PR71901 suspected to be related; David CCed.)
> array_ref_element_size may apply spurious casts which
> in turn end up confusing VN/PRE.
>
> Fixed as follows, bootstrapped on x86_64-unknown-linux-gnu, testing in
> progress.
Thanks, this resolves PR71893 for nvptx:
> PR tree-optimization/71893
> * tree-ssa-pre.c (create_component_ref_by_pieces_1): Compensate
> for sizetype cast added by array_ref_element_size.
> * tree-ssa-sccvn.c (copy_reference_ops_from_ref): Likewise.
>
> Index: gcc/tree-ssa-pre.c
> ===================================================================
> *** gcc/tree-ssa-pre.c (revision 238370)
> --- gcc/tree-ssa-pre.c (working copy)
> *************** create_component_ref_by_pieces_1 (basic_
> *** 2576,2581 ****
> --- 2587,2595 ----
> {
> genop3 = size_binop (EXACT_DIV_EXPR, genop3,
> size_int (TYPE_ALIGN_UNIT (elmt_type)));
> + /* We may have a useless conversion added by
> + array_ref_element_size via copy_reference_opts_from_ref. */
> + STRIP_USELESS_TYPE_CONVERSION (genop3);
> genop3 = find_or_generate_expression (block, genop3, stmts);
> if (!genop3)
> return NULL_TREE;
> Index: gcc/tree-ssa-sccvn.c
> ===================================================================
> *** gcc/tree-ssa-sccvn.c (revision 238370)
> --- gcc/tree-ssa-sccvn.c (working copy)
> *************** copy_reference_ops_from_ref (tree ref, v
> *** 810,815 ****
> --- 810,818 ----
> /* Always record lower bounds and element size. */
> temp.op1 = array_ref_low_bound (ref);
> temp.op2 = array_ref_element_size (ref);
> + /* array_ref_element_size forces the result to sizetype
> + even if that is the same as bitsizetype. */
> + STRIP_USELESS_TYPE_CONVERSION (temp.op2);
> if (TREE_CODE (temp.op0) == INTEGER_CST
> && TREE_CODE (temp.op1) == INTEGER_CST
> && TREE_CODE (temp.op2) == INTEGER_CST)
Grüße
Thomas
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 472 bytes --]
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2016-07-18 7:03 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-07-15 13:20 [PATCH] Fix PR71893 Richard Biener
2016-07-18 7:03 ` Thomas Schwinge
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).