[InstCombine] replace negated operand in fcmp with 0.0
authorSanjay Patel <spatel@rotateright.com>
Thu, 10 Mar 2022 17:37:36 +0000 (12:37 -0500)
committerSanjay Patel <spatel@rotateright.com>
Thu, 10 Mar 2022 17:53:32 +0000 (12:53 -0500)
commit3491f2f4b0336cdb788fed3ff03a4b31c58db14e
tree7579562a0f7464e69d20956ec8ff170d49fa82cd
parent16da22d45a7c4bfceef0fb54f49f5a2ace2e0911
[InstCombine] replace negated operand in fcmp with 0.0

X (any pred) -X --> X (any pred) 0.0

This works with all FP values and preserves FMF.
Alive2 examples:
https://alive2.llvm.org/ce/z/dj6jhp

This can also create one of the patterns that we match as "fabs"
as shown in one of the test diffs.
llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
llvm/test/Transforms/InstCombine/fabs.ll
llvm/test/Transforms/InstCombine/fcmp.ll