HomePhabricator

[InstSimplify] fold fcmp using isKnownNeverInfinity + isKnownNeverNaN

Authored by spatel on Fri, Jul 24, 12:11 PM.

Description

[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!

Details

Committed
spatelSun, Jul 26, 6:04 AM
Parents
rG912e9e526233: [InstSimplify] add tests for fcmp with infinity constant; NFC
Branches
Unknown
Tags
Unknown