[InstSimplify] fold fcmp using isKnownNeverInfinity + isKnownNeverNaN
authorSanjay Patel <spatel@rotateright.com>
Fri, 24 Jul 2020 19:11:02 +0000 (15:11 -0400)
committerSanjay Patel <spatel@rotateright.com>
Sun, 26 Jul 2020 13:04:37 +0000 (09:04 -0400)
commitb89ae102e6f5ed3760f1ae5788bd76ef8e9d9490
tree6f77487edae919a39db0e7a2c594810a1435a1a8
parent912e9e526233c54aa08b082c957499fa9124eece
[InstSimplify] fold fcmp using isKnownNeverInfinity + isKnownNeverNaN

Follow-up to D84035 / rG7393d7574c09.
This sidesteps a question of FMF/poison on fcmp raised in PR46077:
http://bugs.llvm.org/PR46077

https://alive2.llvm.org/ce/z/TCsyzD
  define i1 @src(float %x) {
  %0:
    %x42 = fadd nnan ninf float %x, 42.000000
    %r = fcmp ueq float %x42, inf
    ret i1 %r
  }
  =>
  define i1 @tgt(float %x) {
  %0:
    ret i1 0
  }
  Transformation seems to be correct!

https://alive2.llvm.org/ce/z/FQaH7a
  define i1 @src(i8 %x) {
  %0:
    %cast = uitofp i8 %x to float
    %r = fcmp one float inf, %cast
    ret i1 %r
  }
  =>
  define i1 @tgt(i8 %x) {
  %0:
    ret i1 1
  }
  Transformation seems to be correct!
llvm/lib/Analysis/InstructionSimplify.cpp
llvm/test/Transforms/InstSimplify/floating-point-compare.ll