make GVN try to rename inputs to the resultant replaced values, which
authorChris Lattner <sabre@nondot.org>
Mon, 15 Dec 2008 03:46:38 +0000 (03:46 +0000)
committerChris Lattner <sabre@nondot.org>
Mon, 15 Dec 2008 03:46:38 +0000 (03:46 +0000)
cleans up the generated code a bit.  This should have the added benefit of
not randomly renaming functions/globals like my previous patch did. :)

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

lib/Transforms/Scalar/GVN.cpp
test/Transforms/GVN/2007-07-26-InterlockingLoops.ll
test/Transforms/GVN/2007-07-26-PhiErasure.ll
test/Transforms/GVN/2007-07-31-NoDomInherit.ll
test/Transforms/GVN/rle-dominated.ll
test/Transforms/GVN/rle-must-alias.ll
test/Transforms/GVN/rle-nonlocal.ll
test/Transforms/GVN/rle-phi-translate.ll
test/Transforms/GVN/rle-semidominated.ll

index 8cfc62768f6ba252a57a0f08342caa879979b26b..d3e15d457a4b62168abd68479d982f989534cab6 100644 (file)
@@ -1040,6 +1040,9 @@ bool GVN::processNonLocalLoad(LoadInst *LI,
     // Perform PHI construction.
     Value* v = GetValueForBlock(LI->getParent(), LI, BlockReplValues, true);
     LI->replaceAllUsesWith(v);
+    
+    if (!isa<GlobalValue>(v))
+      v->takeName(LI);
     if (isa<PointerType>(v->getType()))
       MD->invalidateCachedPointerInfo(v);
     toErase.push_back(LI);
@@ -1135,7 +1138,8 @@ bool GVN::processNonLocalLoad(LoadInst *LI,
   // Perform PHI construction.
   Value* v = GetValueForBlock(LI->getParent(), LI, BlockReplValues, true);
   LI->replaceAllUsesWith(v);
-  v->takeName(LI);
+  if (!isa<GlobalValue>(v))
+    v->takeName(LI);
   if (isa<PointerType>(v->getType()))
     MD->invalidateCachedPointerInfo(v);
   toErase.push_back(LI);
index 1dd1479b482553a229ba31c7fadbf39bebfc2bf9..5403a1bdb5e9dc1b1c74cc76e6cc5f782131bdd0 100644 (file)
@@ -1,5 +1,5 @@
-; RUN: llvm-as < %s | opt -gvn | llvm-dis | not grep {tmp17625 =}
-; RUN: llvm-as < %s | opt -gvn | llvm-dis | not grep {tmp17631 =}
+; RUN: llvm-as < %s | opt -gvn | llvm-dis | grep {tmp17625 = phi i32. }
+; RUN: llvm-as < %s | opt -gvn | llvm-dis | grep {tmp17631.* = phi i32. }
 
 @last = external global [65 x i32*]            ; <[65 x i32*]*> [#uses=1]
 
index 52c5b8e7ec83eabfdcac6d6ea0700adecfae98f5..4925df786d739863ade12fe63ddf5ef36d70acbb 100644 (file)
@@ -1,4 +1,4 @@
-; RUN: llvm-as < %s | opt -gvn | llvm-dis | not grep {tmp298316 =}
+; RUN: llvm-as < %s | opt -gvn | llvm-dis | grep {tmp298316 = phi i32 }
 
        %struct..0anon = type { i32 }
        %struct.FILE = type { i8*, i32, i32, i16, i16, %struct.__sbuf, i32, i8*, i32 (i8*)*, i32 (i8*, i8*, i32)*, i64 (i8*, i64, i32)*, i32 (i8*, i8*, i32)*, %struct.__sbuf, %struct.__sFILEX*, i32, [3 x i8], [1 x i8], %struct.__sbuf, i32, i64 }
index 5dbd34c0cdec25533bba629a19ae8b2af1106c82..6cb7785fcd57010d3e00d25f9c05b5638fcc30a9 100644 (file)
@@ -1,4 +1,4 @@
-; RUN: llvm-as < %s | opt -gvn | llvm-dis | grep tmp51.rle
+; RUN: llvm-as < %s | opt -gvn | llvm-dis | grep {tmp47 = phi i32 }
 
        %struct.anon = type { i32 (i32, i32, i32)*, i32, i32, [3 x i32], i8*, i8*, i8* }
 @debug = external constant i32         ; <i32*> [#uses=0]
index d7c9417bcf75cf7299ca28cc606d52bad0af011f..0d517178675ed97420f1eb817a43a311bd01910f 100644 (file)
@@ -1,4 +1,4 @@
-; RUN: llvm-as < %s | opt -gvn | llvm-dis | not grep DEAD
+; RUN: llvm-as < %s | opt -gvn | llvm-dis | grep load | count 2
 
 define i32 @main(i32** %p) {
 block1:
@@ -14,7 +14,7 @@ block3:
   br label %block4
 
 block4:
-  %DEAD = load i32** %p
-  %c = load i32* %DEAD
-  ret i32 %c
+  %c = load i32** %p
+  %d = load i32* %c
+  ret i32 %d
 }
index 7108916d2772a396c8c395672c9008c3c6ae07c1..ada4398571894e5a8419a9e004572558780f696b 100644 (file)
@@ -1,4 +1,4 @@
-; RUN: llvm-as < %s | opt -gvn | llvm-dis | grep {DEAD.rle = phi i32}
+; RUN: llvm-as < %s | opt -gvn | llvm-dis | grep {DEAD = phi i32 }
 ; XFAIL: *
 
 ; FIXME: GVN should eliminate the fully redundant %9 GEP which 
index 1618d05efb5f6b68d5b9cae2f669d3b7912bb243..d93223131d7959306af33df84c60b2efc6bbfc19 100644 (file)
@@ -1,4 +1,4 @@
-; RUN: llvm-as < %s | opt -gvn | llvm-dis | not grep {DEAD =}
+; RUN: llvm-as < %s | opt -gvn | llvm-dis | grep {%DEAD = phi i32. }
 
 define i32 @main(i32** %p) {
 block1:
index 0f9c58ffac8dce20327fbb8a40f17d94ada3cb9e..b5311eec59c4c10ac79b876f7b8df2b7babe9fb7 100644 (file)
@@ -1,5 +1,5 @@
-; RUN: llvm-as < %s | opt -gvn | llvm-dis | grep {%cv.rle = phi i32}
-; RUN: llvm-as < %s | opt -gvn | llvm-dis | grep {%bv.rle = phi i32}
+; RUN: llvm-as < %s | opt -gvn | llvm-dis | grep {%cv = phi i32}
+; RUN: llvm-as < %s | opt -gvn | llvm-dis | grep {%bv = phi i32}
 target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:128:128"
 target triple = "i386-apple-darwin7"
 
index 95ee56a39c01aeaa455715924ac2a268354c7cea..5c11b06e73276c4f36dd31303e8b01391d0cfb92 100644 (file)
@@ -1,4 +1,4 @@
-; RUN: llvm-as < %s | opt -gvn | llvm-dis | not grep {DEAD =}
+; RUN: llvm-as < %s | opt -gvn | llvm-dis | grep {DEAD = phi i32 }
 
 define i32 @main(i32* %p) {
 block1: