gcc trunk rev254211, x86_64. > cat f.cpp template <typename a, int b> struct c { typedef a d[b]; static a e(d f, int g) { return f[g]; } }; template <typename a, int b> struct B { typedef c<a, b> h; typename h::d i; long j; a at() { return h::e(i, j); } }; int k, m, r, s, t; char l, n, q; short o, p, w; struct C { int u; }; B<C, 4> v; void x() { if (((p > (q ? v.at().u : k)) >> l - 226) + !(n ^ r * m)) s = ((-(((p > (q ? v.at().u : k)) >> l - 226) + !(n ^ r * m)) < 0) / (-(((p > (q ? v.at().u : k)) >> l - 226) + !(n ^ r * m)) ^ -25 & o) && p) >> (0 <= 0 ? 0 || (-(((p > (q ? v.at().u : k)) >> l - 226) + !(n ^ r * m)) < 0) / (-(((p > (q ? v.at().u : k)) >> l - 226) + !(n ^ r * m)) ^ -25 & o) : 0); w = (p > (q ? v.at().u : k)) >> l - 226; t = !(n ^ r * m); } > gcc -O2 -c f.cpp f.cpp: In function ‘void x()’: f.cpp:34:1: error: insn does not satisfy its constraints: } ^ (insn 77 75 37 4 (parallel [ (set (reg:CCZ 17 flags) (compare:CCZ (plus:SI (reg:SI 0 ax [orig:95 _9 ] [95]) (reg:SI 1 dx [orig:102 _16 ] [102])) (const_int 0 [0]))) (set (reg:SI 2 cx [orig:103 _17 ] [103]) (plus:SI (reg:SI 0 ax [orig:95 _9 ] [95]) (reg:SI 1 dx [orig:102 _16 ] [102]))) ]) "f.cpp":19 225 {*addsi_2} (expr_list:REG_UNUSED (reg:SI 2 cx [orig:103 _17 ] [103]) (nil))) during RTL pass: cprop_hardreg f.cpp:34:1: internal compiler error: in extract_constrain_insn, at recog.c:2207 0x61c877 _fatal_insn(char const*, rtx_def const*, char const*, int, char const*) ../../gcc/gcc/rtl-error.c:108 0x61c89d _fatal_insn_not_found(rtx_def const*, char const*, int, char const*) ../../gcc/gcc/rtl-error.c:118 0xdf60bd extract_constrain_insn(rtx_insn*) ../../gcc/gcc/recog.c:2207 0xdff55f copyprop_hardreg_forward_1 ../../gcc/gcc/regcprop.c:790 0xe001df execute ../../gcc/gcc/regcprop.c:1296 Please submit a full bug report, with preprocessed source if appropriate. Please include the complete backtrace with any bug report. See <https://gcc.gnu.org/bugs/> for instructions.
Started with r253764. I believe that patch should have been reverted at least due to the compile time regressions.
Created attachment 42502 [details] gcc8-pr82778.patch The following untested patch ought to fix it. recog_memoized doesn't handle the important part insn_invalid_p does: /* After reload, verify that all constraints are satisfied. */ so it happily created an instruction that is wrong after reload. I still wonder if the patch shouldn't be reverted or at least if the changes can't be limited to targets that would benefit from that (perhaps target hook to signal it needs it)?
Dup of PR 82597? Michael has posted a patch at https://gcc.gnu.org/ml/gcc-patches/2017-10/msg01317.html waiting for review. On the reversion: Unfortunately, I don't have any time to work on improving the approach in that patch to address the compile-time implications. Michael, if you don't plan to work on that either, can you please revert it? If we end up reverting it, I guess we won't need to apply any fix for these ICEs.
Author: jakub Date: Wed Nov 1 21:52:21 2017 New Revision: 254328 URL: https://gcc.gnu.org/viewcvs?rev=254328&root=gcc&view=rev Log: PR rtl-optimization/82778 PR rtl-optimization/82597 * compare-elim.c (struct comparison): Add in_a_setter field. (find_comparison_dom_walker::before_dom_children): Remove killed bitmap and df_simulate_find_defs call, instead walk the defs. Compute last_setter and initialize in_a_setter. Merge definitions with first initialization for a few variables. (try_validate_parallel): Use insn_invalid_p instead of recog_memoized. Return insn rather than just the pattern. (try_merge_compare): Fix up comment. Don't uselessly test if in_a is a REG_P. Use cmp->in_a_setter instead of walking UD chains. (execute_compare_elim_after_reload): Remove df_chain_add_problem call. * g++.dg/opt/pr82778.C: New test. 2017-11-01 Michael Collison <michael.collison@arm.com> PR rtl-optimization/82597 * gcc.dg/pr82597.c: New test. Added: trunk/gcc/testsuite/g++.dg/opt/pr82778.C trunk/gcc/testsuite/gcc.dg/pr82597.c Modified: trunk/gcc/ChangeLog trunk/gcc/compare-elim.c trunk/gcc/testsuite/ChangeLog
Fixed then.