[PATCH] D22305: [BasicAA] Strip phi nodes, when all incoming values are the same.

Ehsan Amiri via llvm-commits llvm-commits at lists.llvm.org
Wed Jul 13 17:31:10 PDT 2016


amehsan added inline comments.

================
Comment at: lib/Analysis/BasicAliasAnalysis.cpp:1427
@@ -1406,3 +1426,3 @@
   // Figure out what objects these things are pointing to if we can.
-  const Value *O1 = GetUnderlyingObject(V1, DL, MaxLookupSearchDepth);
-  const Value *O2 = GetUnderlyingObject(V2, DL, MaxLookupSearchDepth);
+  if (O1 == nullptr)
+    O1 = GetUnderlyingObject(V1, DL, MaxLookupSearchDepth);
----------------
hfinkel wrote:
> Because GetUnderlyingObject is depth limited, as we walk up the use/def chain, we get closer to the real underlying object (in those somewhat-rare cases where we actually hit the depth cutoff). I'm quite happy to not do redundant work here, but we also don't want to regress on complex code either. I recommend trying something like this:
> 
>   O1 = GetUnderlyingObject(O1 ? O1 : V1, DL, O1 ? 1 : MaxLookupSearchDepth).
> 
Unless I am missing something, your suggested code, will change the behavior. MaxLookupSearchDepth is constant and does not change anywhere. So if we call aliasCheck with the exact same V1 again, we will call GetUnderlyingObject with exact same parameters. Given there has been no code change since the first call, the result will be exactly the same. O1 and O2 will be non-null only if we are passing exact same V1 (or V2) again to aliasCheck. So the proposed code change here, does not cause any change in the behavior. 



http://reviews.llvm.org/D22305





More information about the llvm-commits mailing list