Though the previous xform applies to literally dozens (hundreds?) of variables
authorChris Lattner <sabre@nondot.org>
Sun, 12 Dec 2004 06:03:06 +0000 (06:03 +0000)
committerChris Lattner <sabre@nondot.org>
Sun, 12 Dec 2004 06:03:06 +0000 (06:03 +0000)
in SPEC, the subsequent optimziations that we are after don't play with
with FP values, so disable this xform for them.  Really we just don't want
stuff like:

double G;   (always 0 or 412312.312)
  = G;

turning into:

bool G_b;
  = G_b ? 412312.312 : 0;

We'd rather just do the load.

-Chris

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@18819 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Transforms/IPO/GlobalOpt.cpp

index 6309c3b5081445263a8856b11a8d9cca97b29e10..5ae693b65b2afec3aba70a0a693f44e55cd3ced0 100644 (file)
@@ -954,7 +954,8 @@ bool GlobalOpt::ProcessInternalGlobal(GlobalVariable *GV,
       // Otherwise, if the global was not a boolean, we can shrink it to be a
       // boolean.
       if (Constant *SOVConstant = dyn_cast<Constant>(GS.StoredOnceValue))
-        if (GV->getType()->getElementType() != Type::BoolTy) {
+        if (GV->getType()->getElementType() != Type::BoolTy &&
+            !GV->getType()->getElementType()->isFloatingPoint()) {
           DEBUG(std::cerr << "   *** SHRINKING TO BOOL: " << *GV);
           ShrinkGlobalToBoolean(GV, SOVConstant);
           ++NumShrunkToBool;