[patch] fix comment on findGCD

David Tweed david.tweed at arm.com
Fri Jan 3 02:24:50 PST 2014


Hi,

This looks reasonable to me, but the patch's scope has grown sufficiently
I'd
feel more comfortable if one of the original authors of that code commented.

Index: lib/Analysis/DependenceAnalysis.cpp
===================================================================
--- lib/Analysis/DependenceAnalysis.cpp (revision 198188)
+++ lib/Analysis/DependenceAnalysis.cpp (working copy)
@@ -1275,7 +1275,7 @@
 //
 // Program 2.1, page 29.
 // Computes the GCD of AM and BM.
-// Also finds a solution to the equation ax - by = gdc(a, b).
+// Also finds a solution to the equation ax - by = gcd(a, b).
 // Returns true iff the gcd divides Delta.
 static
 bool findGCD(unsigned Bits, APInt AM, APInt BM, APInt Delta,
@@ -1301,11 +1301,11 @@
   // make sure gcd divides Delta
   R = Delta.srem(G);
   if (R != 0)
-    return true; // gcd doesn't divide Delta, no dependence
+    return false; // gcd doesn't divide Delta, no dependence
   Q = Delta.sdiv(G);
   X *= Q;
   Y *= Q;
-  return false;
+  return true;
 }


@@ -1398,7 +1398,7 @@
   APInt AM = ConstSrcCoeff->getValue()->getValue();
   APInt BM = ConstDstCoeff->getValue()->getValue();
   unsigned Bits = AM.getBitWidth();
-  if (findGCD(Bits, AM, BM, ConstDelta->getValue()->getValue(), G, X, Y)) {
+  if (!findGCD(Bits, AM, BM, ConstDelta->getValue()->getValue(), G, X, Y))
{
     // gcd doesn't divide Delta, no dependence
     ++ExactSIVindependence;
     ++ExactSIVsuccesses;
@@ -1802,7 +1802,7 @@
   APInt AM = ConstSrcCoeff->getValue()->getValue();
   APInt BM = ConstDstCoeff->getValue()->getValue();
   unsigned Bits = AM.getBitWidth();
-  if (findGCD(Bits, AM, BM, ConstDelta->getValue()->getValue(), G, X, Y)) {
+  if (!findGCD(Bits, AM, BM, ConstDelta->getValue()->getValue(), G, X, Y))
{
     // gcd doesn't divide Delta, no dependence
     ++ExactRDIVindependence;
     return true;







More information about the llvm-commits mailing list