[llvm] r366976 - [PowerPC] exclude more icmps in LSR which is converted in later hardware loop pass

Chen Zheng via llvm-commits llvm-commits at lists.llvm.org
Wed Jul 24 18:22:08 PDT 2019


Author: shchenz
Date: Wed Jul 24 18:22:08 2019
New Revision: 366976

URL: http://llvm.org/viewvc/llvm-project?rev=366976&view=rev
Log:
[PowerPC] exclude more icmps in LSR which is converted in later hardware loop pass
Differential Revision: https://reviews.llvm.org/D64795

Modified:
    llvm/trunk/lib/Transforms/Scalar/LoopStrengthReduce.cpp
    llvm/trunk/test/CodeGen/PowerPC/ctrloop-le.ll
    llvm/trunk/test/CodeGen/PowerPC/ctrloop-lt.ll

Modified: llvm/trunk/lib/Transforms/Scalar/LoopStrengthReduce.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/LoopStrengthReduce.cpp?rev=366976&r1=366975&r2=366976&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/LoopStrengthReduce.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/LoopStrengthReduce.cpp Wed Jul 24 18:22:08 2019
@@ -3265,12 +3265,12 @@ void LSRInstance::CollectFixupsAndInitia
     // requirements for both N and i at the same time. Limiting this code to
     // equality icmps is not a problem because all interesting loops use
     // equality icmps, thanks to IndVarSimplify.
-    if (ICmpInst *CI = dyn_cast<ICmpInst>(UserInst))
+    if (ICmpInst *CI = dyn_cast<ICmpInst>(UserInst)) {
+      // If CI can be saved in some target, like replaced inside hardware loop
+      // in PowerPC, no need to generate initial formulae for it.
+      if (SaveCmp && CI == dyn_cast<ICmpInst>(ExitBranch->getCondition()))
+        continue;
       if (CI->isEquality()) {
-        // If CI can be saved in some target, like replaced inside hardware loop
-        // in PowerPC, no need to generate initial formulae for it.
-        if (SaveCmp && CI == dyn_cast<ICmpInst>(ExitBranch->getCondition()))
-          continue;
         // Swap the operands if needed to put the OperandValToReplace on the
         // left, for consistency.
         Value *NV = CI->getOperand(1);
@@ -3298,6 +3298,7 @@ void LSRInstance::CollectFixupsAndInitia
             Factors.insert(-(uint64_t)Factors[i]);
         Factors.insert(-1);
       }
+    }
 
     // Get or create an LSRUse.
     std::pair<size_t, int64_t> P = getUse(S, Kind, AccessTy);

Modified: llvm/trunk/test/CodeGen/PowerPC/ctrloop-le.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/PowerPC/ctrloop-le.ll?rev=366976&r1=366975&r2=366976&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/PowerPC/ctrloop-le.ll (original)
+++ llvm/trunk/test/CodeGen/PowerPC/ctrloop-le.ll Wed Jul 24 18:22:08 2019
@@ -2,9 +2,6 @@
 target datalayout = "E-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v128:128:128-n32:64"
 target triple = "powerpc64-unknown-linux-gnu"
 
-; XFAIL: *
-; SE needs improvement
-
 ; CHECK: test_pos1_ir_sle
 ; CHECK: bdnz
 ; a < b

Modified: llvm/trunk/test/CodeGen/PowerPC/ctrloop-lt.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/PowerPC/ctrloop-lt.ll?rev=366976&r1=366975&r2=366976&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/PowerPC/ctrloop-lt.ll (original)
+++ llvm/trunk/test/CodeGen/PowerPC/ctrloop-lt.ll Wed Jul 24 18:22:08 2019
@@ -2,9 +2,6 @@
 target datalayout = "E-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v128:128:128-n32:64"
 target triple = "powerpc64-unknown-linux-gnu"
 
-; XFAIL: *
-; SE needs improvement
-
 ; CHECK: test_pos1_ir_slt
 ; CHECK: bdnz
 ; a < b
@@ -35,7 +32,6 @@ for.end:
 
 
 ; CHECK: test_pos2_ir_slt
-; FIXME: Support this loop!
 ; CHECK: bdnz
 ; a < b
 define void @test_pos2_ir_slt(i8* nocapture %p, i32 %a, i32 %b) nounwind {
@@ -65,7 +61,6 @@ for.end:
 
 
 ; CHECK: test_pos4_ir_slt
-; FIXME: Support this loop!
 ; CHECK: bdnz
 ; a < b
 define void @test_pos4_ir_slt(i8* nocapture %p, i32 %a, i32 %b) nounwind {




More information about the llvm-commits mailing list