https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99739
Bug ID: 99739 Summary: [11 Regression] missing optimization of a repeated conditional Product: gcc Version: 11.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: msebor at gcc dot gnu.org Target Milestone: --- Prior to r11-5805 both ff() and gg() in the test case below resulted in optimal code. With the change, the second conditional in g() is no longer recognized as equivalent to the first and so the function isn't optimized as expected. Incidentally, the same regression was also introduced once before: in r235653. $ cat x.c && gcc -O1 -S -Wall -fdump-tree-optimized=/dev/stdout x.c static inline int f (int i, int j, int k) { int x = 1; if (i && j && k) x = 2; if (i && j && k) return x; return -1; } void ff (int i, int j, int k) { int x = f (i, j, k); if (x == 1) __builtin_abort (); } static inline int g (int i, int j, int k) { int x = 1; if (i && j && k) x = 2; if (i && k && j) return x; return -1; } void gg (int i, int j, int k) { int x = g (i, j, k); if (x == 1) __builtin_abort (); } ;; Function ff (ff, funcdef_no=1, decl_uid=1951, cgraph_uid=2, symbol_order=1) void ff (int i, int j, int k) { <bb 2> [local count: 1073741824]: return; } ;; Function gg (gg, funcdef_no=3, decl_uid=1963, cgraph_uid=4, symbol_order=3) Removing basic block 6 Removing basic block 7 void gg (int i, int j, int k) { _Bool _7; _Bool _8; _Bool _11; _Bool _14; _Bool _16; <bb 2> [local count: 1073741824]: _7 = i_2(D) != 0; _8 = j_3(D) != 0; _14 = k_4(D) != 0; _11 = _7 & _14; _16 = _8 & _11; if (_16 != 0) goto <bb 3>; [94.27%] else goto <bb 5>; [5.73%] <bb 3> [local count: 1012175616]: if (k_4(D) != 0) goto <bb 5>; [100.00%] else goto <bb 4>; [0.00%] <bb 4> [count: 0]: __builtin_abort (); <bb 5> [local count: 1073741824]: return; }