[PATCH] D126190: [InstCombine] Add combine for fcmp sqrt(x),C --> fcmp x,C*C

Sanjay Patel via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon May 23 11:52:06 PDT 2022


spatel added inline comments.


================
Comment at: llvm/test/Transforms/InstCombine/fcmp.ll:1234
+  %sqrt = call double @llvm.sqrt.f64(double %v)
+  %cmp = fcmp fast ogt double %sqrt, -2.000000e+00
+  ret i1 %cmp
----------------
spatel wrote:
> Can we handle this kind of example as a preliminary patch? There's no fast-math required if we are checking if the result of sqrt is or is not negative (but we should test several predicates to verify that we have the correct behavior with NAN):
> https://alive2.llvm.org/ce/z/EeYGLt
> https://alive2.llvm.org/ce/z/X7qsg2
Note that we should already reduce some compares via:
https://github.com/llvm/llvm-project/blob/main/llvm/lib/Analysis/InstructionSimplify.cpp#L3995


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D126190



More information about the llvm-commits mailing list