https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112659
--- Comment #8 from Andrew Pinski <pinskia at gcc dot gnu.org> --- (In reply to Andrew Pinski from comment #7) > This is the pattern I added for the plus case: > ``` > (for cnd (cond vec_cond) > ... > /* (a != CST1) ? (a + CST2) : 0 -> (a + CST2) iff CST1 == -CST2 */ > (simplify > (cnd (ne @0 uniform_integer_cst_p@1) > (plus@3 @0 uniform_integer_cst_p@2) > integer_zerop) > (if (wi::to_wide (uniform_integer_cst_p (@1)) > == -wi::to_wide (uniform_integer_cst_p (@2))) > @3)) > ) > ``` Thinking about this slightly more, we should be able to handle (which LLVM does not currently handles): ``` int optb(int v, int b) { // b = 8; if (v != -b) return v + b; else return 0; } ``` too. Which means this is similar to PR 113265. So I should fix PR 113265 first and then add the pattern for this case.