[llvm-branch-commits] [llvm-branch] r113265 - in /llvm/branches/release_28: ./ lib/Transforms/InstCombine/InstCombineCasts.cpp test/Transforms/InstCombine/2010-07-19-sqrt.ll test/Transforms/InstCombine/sqrt.ll

Bill Wendling isanbard at gmail.com
Tue Sep 7 13:14:32 PDT 2010


Author: void
Date: Tue Sep  7 15:14:32 2010
New Revision: 113265

URL: http://llvm.org/viewvc/llvm-project?rev=113265&view=rev
Log:
Approved by Chris:

$ svn merge -c 113257 https://llvm.org/svn/llvm-project/llvm/trunk
--- Merging r113257 into '.':
A    test/Transforms/InstCombine/sqrt.ll
D    test/Transforms/InstCombine/2010-07-19-sqrt.ll

Renaming test.

$ svn merge -c 113260 https://llvm.org/svn/llvm-project/llvm/trunk
--- Merging r113260 into '.':
U    test/Transforms/InstCombine/sqrt.ll
U    lib/Transforms/InstCombine/InstCombineCasts.cpp

Log:
Fix a serious performance regression introduced by r108687 on linux:
turning (fptrunc (sqrt (fpext x))) -> (sqrtf x)  is great, but we have
to delete the original sqrt as well.  Not doing so causes us to do 
two sqrt's when building with -fmath-errno (the default on linux).


Added:
    llvm/branches/release_28/test/Transforms/InstCombine/sqrt.ll
      - copied, changed from r113257, llvm/trunk/test/Transforms/InstCombine/sqrt.ll
Removed:
    llvm/branches/release_28/test/Transforms/InstCombine/2010-07-19-sqrt.ll
Modified:
    llvm/branches/release_28/   (props changed)
    llvm/branches/release_28/lib/Transforms/InstCombine/InstCombineCasts.cpp

Propchange: llvm/branches/release_28/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Tue Sep  7 15:14:32 2010
@@ -1,2 +1,2 @@
 /llvm/branches/Apple/Pertwee:110850,110961
-/llvm/trunk:113109,113123,113146,113158
+/llvm/trunk:113109,113123,113146,113158,113257,113260

Modified: llvm/branches/release_28/lib/Transforms/InstCombine/InstCombineCasts.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/release_28/lib/Transforms/InstCombine/InstCombineCasts.cpp?rev=113265&r1=113264&r2=113265&view=diff
==============================================================================
--- llvm/branches/release_28/lib/Transforms/InstCombine/InstCombineCasts.cpp (original)
+++ llvm/branches/release_28/lib/Transforms/InstCombine/InstCombineCasts.cpp Tue Sep  7 15:14:32 2010
@@ -1139,7 +1139,7 @@
         Arg->getOperand(0)->getType()->isFloatTy()) {
       Function *Callee = Call->getCalledFunction();
       Module *M = CI.getParent()->getParent()->getParent();
-      Constant* SqrtfFunc = M->getOrInsertFunction("sqrtf", 
+      Constant *SqrtfFunc = M->getOrInsertFunction("sqrtf", 
                                                    Callee->getAttributes(),
                                                    Builder->getFloatTy(),
                                                    Builder->getFloatTy(),
@@ -1147,6 +1147,11 @@
       CallInst *ret = CallInst::Create(SqrtfFunc, Arg->getOperand(0),
                                        "sqrtfcall");
       ret->setAttributes(Callee->getAttributes());
+      
+      
+      // Remove the old Call.  With -fmath-errno, it won't get marked readnone.
+      Call->replaceAllUsesWith(UndefValue::get(Call->getType()));
+      EraseInstFromFunction(*Call);
       return ret;
     }
   }

Removed: llvm/branches/release_28/test/Transforms/InstCombine/2010-07-19-sqrt.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/release_28/test/Transforms/InstCombine/2010-07-19-sqrt.ll?rev=113264&view=auto
==============================================================================
--- llvm/branches/release_28/test/Transforms/InstCombine/2010-07-19-sqrt.ll (original)
+++ llvm/branches/release_28/test/Transforms/InstCombine/2010-07-19-sqrt.ll (removed)
@@ -1,16 +0,0 @@
-; RUN: opt -S -instcombine %s | FileCheck %s
-
-define float @foo(float %x) nounwind readnone ssp {
-entry:
-; CHECK-NOT: fpext
-; CHECK-NOT: sqrt(
-; CHECK: sqrtf(
-; CHECK-NOT: fptrunc
-  %conv = fpext float %x to double                ; <double> [#uses=1]
-  %call = tail call double @sqrt(double %conv) nounwind ; <double> [#uses=1]
-  %conv1 = fptrunc double %call to float          ; <float> [#uses=1]
-; CHECK: ret float
-  ret float %conv1
-}
-
-declare double @sqrt(double) readnone

Copied: llvm/branches/release_28/test/Transforms/InstCombine/sqrt.ll (from r113257, llvm/trunk/test/Transforms/InstCombine/sqrt.ll)
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/release_28/test/Transforms/InstCombine/sqrt.ll?p2=llvm/branches/release_28/test/Transforms/InstCombine/sqrt.ll&p1=llvm/trunk/test/Transforms/InstCombine/sqrt.ll&r1=113257&r2=113265&rev=113265&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/InstCombine/sqrt.ll (original)
+++ llvm/branches/release_28/test/Transforms/InstCombine/sqrt.ll Tue Sep  7 15:14:32 2010
@@ -1,16 +1,32 @@
 ; RUN: opt -S -instcombine %s | FileCheck %s
 
-define float @foo(float %x) nounwind readnone ssp {
+define float @test1(float %x) nounwind readnone ssp {
 entry:
+; CHECK: @test1
 ; CHECK-NOT: fpext
 ; CHECK-NOT: sqrt(
 ; CHECK: sqrtf(
 ; CHECK-NOT: fptrunc
   %conv = fpext float %x to double                ; <double> [#uses=1]
-  %call = tail call double @sqrt(double %conv) nounwind ; <double> [#uses=1]
+  %call = tail call double @sqrt(double %conv) readnone nounwind ; <double> [#uses=1]
   %conv1 = fptrunc double %call to float          ; <float> [#uses=1]
 ; CHECK: ret float
   ret float %conv1
 }
 
-declare double @sqrt(double) readnone
+declare double @sqrt(double)
+
+; PR8096
+define float @test2(float %x) nounwind readnone ssp {
+entry:
+; CHECK: @test2
+; CHECK-NOT: fpext
+; CHECK-NOT: sqrt(
+; CHECK: sqrtf(
+; CHECK-NOT: fptrunc
+  %conv = fpext float %x to double                ; <double> [#uses=1]
+  %call = tail call double @sqrt(double %conv) nounwind ; <double> [#uses=1]
+  %conv1 = fptrunc double %call to float          ; <float> [#uses=1]
+; CHECK: ret float
+  ret float %conv1
+}





More information about the llvm-branch-commits mailing list