float comparison to double 'zero' constant can just be a float 'zero.'
authorJim Grosbach <grosbach@apple.com>
Fri, 30 Sep 2011 18:45:50 +0000 (18:45 +0000)
committerJim Grosbach <grosbach@apple.com>
Fri, 30 Sep 2011 18:45:50 +0000 (18:45 +0000)
commitcbf676b3ba907f72405a02938f5cd85fb3e6a46c
tree77ae94899d0648d1ef6b8768a1f1bcdedea556f3
parentd98f838284b7c539f274bb21820b2df3588a295e
float comparison to double 'zero' constant can just be a float 'zero.'

InstCombine was incorrectly considering the conversion of the constant
zero to be unsafe.

We want to transform:
define float @bar(float %x) nounwind readnone optsize ssp {
  %conv = fpext float %x to double
  %cmp = fcmp olt double %conv, 0.000000e+00
  %conv1 = zext i1 %cmp to i32
  %conv2 = sitofp i32 %conv1 to float
  ret float %conv2
}

Into:
define float @bar(float %x) nounwind readnone optsize ssp {
  %cmp = fcmp olt float %x, 0.000000e+00   ; <---- This
  %conv1 = zext i1 %cmp to i32
  %conv2 = sitofp i32 %conv1 to float
  ret float %conv2
}

rdar://10215914

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@140869 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Transforms/InstCombine/InstCombineCompares.cpp
test/Transforms/InstCombine/fcmp.ll