https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114734

--- Comment #9 from Richard Biener <rguenth at gcc dot gnu.org> ---
(In reply to Robin Dapp from comment #8)
> Created attachment 58037 [details]
> Expand dump
> 
> Dump attached.  Insn 209 is the problematic one.
> The changing from _911 to 1078 happens in internal-fn.cc:expand_call_mem_ref
> (and not via TER).
> The lookup there is simple and I was also wondering if there is some
> single_imm_use or so missing.

Nah, it's invalid to do that.  You have to use get_gimple_for_ssa_name instead
and handle a NULL return.  Alternatively the code could check for
no SSA use on the def (to catch _1 = &a).

So the error is in r8-6047-g65dd1346027bb5 which makes it a quite old
wrong-code issue.  And yes, Richard S. wrote that.

Can you check if the following fixes the issue?  (untested besides compiling
it)

diff --git a/gcc/internal-fn.cc b/gcc/internal-fn.cc
index 2c764441cde..0a7053c2286 100644
--- a/gcc/internal-fn.cc
+++ b/gcc/internal-fn.cc
@@ -53,6 +53,8 @@ along with GCC; see the file COPYING3.  If not see
 #include "rtl-iter.h"
 #include "gimple-range.h"
 #include "fold-const-call.h"
+#include "tree-ssa-live.h"
+#include "tree-outof-ssa.h"

 /* For lang_hooks.types.type_for_mode.  */
 #include "langhooks.h"
@@ -2964,8 +2966,8 @@ expand_call_mem_ref (tree type, gcall *stmt, int index)
   tree tmp = addr;
   if (TREE_CODE (tmp) == SSA_NAME)
     {
-      gimple *def = SSA_NAME_DEF_STMT (tmp);
-      if (gimple_assign_single_p (def))
+      gimple *def = get_gimple_for_ssa_name (tmp);
+      if (def && gimple_assign_single_p (def))
        tmp = gimple_assign_rhs1 (def);
     }

Reply via email to