We can only fold a load into an op if there is exactly one use of the value.
authorChris Lattner <sabre@nondot.org>
Wed, 12 Jan 2005 18:38:26 +0000 (18:38 +0000)
committerChris Lattner <sabre@nondot.org>
Wed, 12 Jan 2005 18:38:26 +0000 (18:38 +0000)
Checking to see if the load has two uses is not equivalent, as the chain
value may have zero uses.

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

lib/Target/X86/X86ISelPattern.cpp

index 194c2fa517c0695f811353642050baefbf0cdb6f..cc22506295fef88c60b8551f3a0b7ed462d95609 100644 (file)
@@ -979,7 +979,8 @@ bool ISel::isFoldableLoad(SDOperand Op) {
   // If this load has already been emitted, we clearly can't fold it.
   if (ExprMap.count(Op)) return false;
 
-  return Op.Val->use_size() == 2;
+  // Finally, there can only be one use of its value.
+  return Op.Val->hasNUsesOfValue(1, 0);
 }
 
 /// EmitFoldedLoad - Ensure that the arguments of the load are code generated,