Convert fcmp with 0.0 from casted integers to icmp
authorMatt Arsenault <Matthew.Arsenault@amd.com>
Tue, 6 Jan 2015 15:50:59 +0000 (15:50 +0000)
committerMatt Arsenault <Matthew.Arsenault@amd.com>
Tue, 6 Jan 2015 15:50:59 +0000 (15:50 +0000)
commit55e7312cd86b00bb4d9192615a3c7d25e46fbdaa
tree4e141574259fa508cd6ebe109e6707f0306be985
parentf8ae533f3d91881366d64f1b4f49d85615010f35
Convert fcmp with 0.0 from casted integers to icmp

This is already handled in general when it is known the
conversion can't lose bits with smaller integer types
casted into wider floating point types.

This pattern happens somewhat often in GPU programs that cast
workitem intrinsics to float, which are often compared with 0.

Specifically handle the special case of compares with zero which
should also be known to not lose information. I had a more general
version of this which allows equality compares if the casted float is
exactly representable in the integer, but I'm not 100% confident that
is always correct.

Also fold cases that aren't integers to true / false.

llvm-svn: 225265
llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
llvm/test/Transforms/InstCombine/cast-int-fcmp-eq-0.ll [new file with mode: 0644]