[InstCombine] fold logic-of-nan-fcmps (PR41069)
authorSanjay Patel <spatel@rotateright.com>
Tue, 19 Mar 2019 16:39:17 +0000 (16:39 +0000)
committerSanjay Patel <spatel@rotateright.com>
Tue, 19 Mar 2019 16:39:17 +0000 (16:39 +0000)
commit5b820323ca11a7ed2f335873836ead6b5befd7b9
treeb77fd132a3f4e0b37ed1037d6e0b511c06f2c9ae
parent47c2bd2b349fabc88702893a3a160df3543a1b19
[InstCombine] fold logic-of-nan-fcmps (PR41069)

Combine 2 fcmps that are checking for nan-ness:
   and (fcmp ord X, 0), (and (fcmp ord Y, 0), Z) --> and (fcmp ord X, Y), Z
   or  (fcmp uno X, 0), (or  (fcmp uno Y, 0), Z) --> or  (fcmp uno X, Y), Z

This is an exact match for a minimal reassociation pattern.
If we want to handle this more generally that should go in
the reassociate pass and allow removing this code.

This should fix:
https://bugs.llvm.org/show_bug.cgi?id=41069

llvm-svn: 356471
llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp
llvm/test/Transforms/InstCombine/and-fcmp.ll
llvm/test/Transforms/InstCombine/or-fcmp.ll