This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH] Fix ICE in VN
- From: Richard Biener <rguenther at suse dot de>
- To: gcc-patches at gcc dot gnu dot org
- Date: Tue, 24 Sep 2019 12:10:08 +0200 (CEST)
- Subject: [PATCH] Fix ICE in VN
The following fixes an ICE privately reported to me by Jeff.
Bootstrapped and tested on x86_64-unknown-linux-gnu, applied to trunk.
Richard.
2019-09-24 Richard Biener <rguenther@suse.de>
* tree-ssa-sccvn.c (vn_reference_lookup_3): Valueize MEM_REF
base.
* gcc.dg/torture/20190924-1.c: New testcase.
Index: gcc/tree-ssa-sccvn.c
===================================================================
--- gcc/tree-ssa-sccvn.c (revision 276054)
+++ gcc/tree-ssa-sccvn.c (working copy)
@@ -2935,8 +2935,9 @@ vn_reference_lookup_3 (ao_ref *ref, tree
else
return (void *)-1;
}
- if (TREE_CODE (rhs) != SSA_NAME
- && TREE_CODE (rhs) != ADDR_EXPR)
+ if (TREE_CODE (rhs) == SSA_NAME)
+ rhs = SSA_VAL (rhs);
+ else if (TREE_CODE (rhs) != ADDR_EXPR)
return (void *)-1;
/* The bases of the destination and the references have to agree. */
Index: gcc/testsuite/gcc.dg/torture/20190924-1.c
===================================================================
--- gcc/testsuite/gcc.dg/torture/20190924-1.c (nonexistent)
+++ gcc/testsuite/gcc.dg/torture/20190924-1.c (working copy)
@@ -0,0 +1,17 @@
+/* { dg-do compile } */
+
+struct acct_gather_energy {
+ int base_consumed_energy;
+ int consumed_energy;
+ int previous_consumed_energy;
+};
+static struct acct_gather_energy xcc_energy;
+struct acct_gather_energy *new;
+int _get_joules_task(int first)
+{
+ if (!first && new->previous_consumed_energy)
+ first = 1;
+ new->base_consumed_energy = new->consumed_energy;
+ __builtin_memcpy(&xcc_energy, new, sizeof(struct acct_gather_energy));
+ return xcc_energy.base_consumed_energy;
+}