Hello, this is a variant of patch I tested. After looking into the issue more, I think we don't really need to check types to be compatible (or we want to check it in other references, too). It seems to me that we should be able to drop /* Verify that access happens in similar types. */ if (!types_compatible_p (TREE_TYPE (arg0), TREE_TYPE (arg1))) return 0; from MEM_REF, too.
I had bit hard time creating a testcase running into an ICE https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68062 With C FE I only know how to produce VCEs by vector conversions. Will play with it more tomorrow. The code patch hits about 1k times during bootstrap. Bootstrapped/regtested ppc64-linux, OK? Index: fold-const.c =================================================================== --- fold-const.c (revision 228933) +++ fold-const.c (working copy) @@ -2960,6 +2962,7 @@ operand_equal_p (const_tree arg0, const_ case REALPART_EXPR: case IMAGPART_EXPR: + case VIEW_CONVERT_EXPR: return OP_SAME (0); case TARGET_MEM_REF: