https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89595
Bug ID: 89595 Summary: [8/9 Regression] DOM miscompiles code Product: gcc Version: 9.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: rguenth at gcc dot gnu.org Target Milestone: --- The testcase below is miscompiled at -O1+ because DOM doesn't visit stmts in a folded sequence other than the last for value-ranges so we end up with Visiting statement: i_1 = val_2(D) > 0 ? i_6 : 0; Meeting int [val_2(D), val_2(D)] EQUIVALENCES: { val_2(D) } (1 elements) and int [0, 0] to VARYING Optimizing statement i_1 = val_2(D) > 0 ? i_6 : 0; Replaced 'i_6' with variable 'val_2(D)' gimple_simplified to _9 = MAX_EXPR <val_2(D), 0>; i_1 = _9; Folded to: i_1 = _9; LKUP STMT i_1 = _9 ==== ASGN i_1 = _9 ... Visiting PHI node: i_3 = PHI <0(2), _9(3)> Argument #0 (2 -> 4 executable) 0: int [0, 0] Argument #1 (3 -> 4 executable) _9: UNDEFINED Meeting int [0, 0] and UNDEFINED to int [0, 0] LKUP STMT i_3 = PHI <0, _9> 2>>> STMT i_3 = PHI <0, _9> <<<< STMT i_3 = PHI <0, _9> Optimizing statement bb_5: Optimizing statement return i_3; Replaced 'i_3' with constant '0' int __attribute__((noipa)) __GIMPLE(startwith("dom1")) bar(int cond, int val) { int i; if (0 != 0) goto bb_6; else goto bb_2; bb_2: if (cond_5(D) != 0) goto bb_4; else goto bb_5; bb_4: i_6 = val_2(D); i_1 = val_2(D) > 0 ? i_6 : 0; bb_5: i_3 = __PHI (bb_4: i_1, bb_2: 0); return i_3; bb_6: i_4 = 1; i_9 = 2; goto bb_2; } int main() { if (bar (1, 1) != 1) __builtin_abort (); return 0; }