Don't use std::set_difference when the two sets are sorted differently. Compute
authorOwen Anderson <resistor@mac.com>
Mon, 4 Jun 2007 23:34:56 +0000 (23:34 +0000)
committerOwen Anderson <resistor@mac.com>
Mon, 4 Jun 2007 23:34:56 +0000 (23:34 +0000)
the difference manually instead.

This allows GVNPRE to produce correct analysis for the example in the GVNPRE
paper.

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

lib/Transforms/Scalar/GVNPRE.cpp

index 4f327663c1c7587a95263dfd1706470281d3497b..2bedd1cdea592e8ed3087d3b5791a7068e2262e6 100644 (file)
@@ -420,13 +420,12 @@ bool GVNPRE::runOnFunction(Function &F) {
                      s_ins, ExprLT());
       
       anticIn.clear();
-      std::insert_iterator<std::set<Value*, ExprLT> >  antic_ins(anticIn, 
-                                                             anticIn.begin());
-      std::set_difference(S.begin(), S.end(),
-                          generatedTemporaries[BB].begin(),
-                          generatedTemporaries[BB].end(),
-                          antic_ins,
-                          ExprLT());
+      
+      for (std::set<Value*, ExprLT>::iterator I = S.begin(), E = S.end();
+           I != E; ++I) {
+        if (generatedTemporaries[BB].find(*I) == generatedTemporaries[BB].end())
+          anticIn.insert(*I);
+      }
       
       clean(VN, anticIn);