[PATCH] D123830: [InstCombine] Complete folding of fneg-of-fabs

Sanjay Patel via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Apr 21 05:24:58 PDT 2022


spatel added inline comments.


================
Comment at: llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp:2812
   }
+  // With nnan and nsz
+  // (X <   +/-0.0) ? X : -X --> -fabs(x)
----------------
We don't check 'nnan', so this comment is wrong.

I see that it is copied from above, so that suggests a better solution than only fixing it on this line: can you reduce the code duplication by moving the existing fabs transforms to a helper function or lambda? 

Maybe it is easier if we match the negated value in the select first (and give it the name 'X'), then match the compare?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D123830/new/

https://reviews.llvm.org/D123830



More information about the llvm-commits mailing list