fix minsize detection: minsize attribute implies optimizing for size
[oota-llvm.git] / lib / Target / X86 / X86InstrInfo.cpp
index c37f5c8f087920cc37e58ff21d29d919b53563c5..d65c2d737643e193f20110ff2681584185bbe090 100644 (file)
@@ -5347,11 +5347,8 @@ MachineInstr *X86InstrInfo::foldMemoryOperandImpl(
   // Check switch flag
   if (NoFusing) return nullptr;
 
-  // Unless optimizing for size, don't fold to avoid partial
-  // register update stalls
-  // FIXME: Use Function::optForSize().
-  if (!MF.getFunction()->hasFnAttribute(Attribute::OptimizeForSize) &&
-      hasPartialRegUpdate(MI->getOpcode()))
+  // Avoid partial register update stalls unless optimizing for size.
+  if (!MF.getFunction()->optForSize() && hasPartialRegUpdate(MI->getOpcode()))
     return nullptr;
 
   // Determine the alignment of the load.