https://gcc.gnu.org/bugzilla/show_bug.cgi?id=121595
--- Comment #6 from Andrew Pinski <pinskia at gcc dot gnu.org> --- (In reply to Matteo Nicoli from comment #5) > Created attachment 62175 [details] > A patch to fix 121595 > > I attached a patch for this issue; Hope I haven't violated the coding > standards. I added a couple of tests file in gcc.dg. Probably I should have > added more optimizations in dg-options (currently I only have -O2). Should I > create a different file for each dg-options combination? Just a small suggestion for the match pattern: + (abs (op @0 REAL_CST@1)) + (if (real_zerop (@1) && !flag_trapping_math) You can just do: (abs (op @0 real_zerop@1)) (if (!flag_trapping_math) This should speed up the matching slightly. As far as the testcases are concerned, they look good. Since they are small having one file that just does the function and #including it in the other 2 don't make sense. I do think you should add a few more: `fabs(a + -0.0)`, `fabs(a - 0.0)` and `fabs(a - -0.0)`. (though only for the non-trapping case really). > FAIL: gcc.dg/pr96392.c scan-tree-dump-not optimized " \\+ " > FAIL: gcc.dg/pr96392.c scan-tree-dump-not optimized " \\- " I have not seen that before, I wonder how that iteracts with your new pattern because I can't see how it would.