[polly] r248681 - BlockGenerator: Simplify code generated for scop statements

Tobias Grosser via llvm-commits llvm-commits at lists.llvm.org
Sun Sep 27 04:17:23 PDT 2015


Author: grosser
Date: Sun Sep 27 06:17:22 2015
New Revision: 248681

URL: http://llvm.org/viewvc/llvm-project?rev=248681&view=rev
Log:
BlockGenerator: Simplify code generated for scop statements

After having generated a new user statement a couple of inefficient or trivially
dead instructions may remain. This commit runs instruction simplification over
the newly generated blocks to ensure unneeded instructions are removed right
away.

This commit does not yet add simplification for non-affine subregions.

Modified:
    polly/trunk/lib/CodeGen/BlockGenerators.cpp
    polly/trunk/test/Isl/CodeGen/MemAccess/codegen_address_space.ll
    polly/trunk/test/Isl/CodeGen/OpenMP/new_multidim_access.ll

Modified: polly/trunk/lib/CodeGen/BlockGenerators.cpp
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/CodeGen/BlockGenerators.cpp?rev=248681&r1=248680&r2=248681&view=diff
==============================================================================
--- polly/trunk/lib/CodeGen/BlockGenerators.cpp (original)
+++ polly/trunk/lib/CodeGen/BlockGenerators.cpp Sun Sep 27 06:17:22 2015
@@ -28,6 +28,7 @@
 #include "llvm/IR/IntrinsicInst.h"
 #include "llvm/IR/Module.h"
 #include "llvm/Transforms/Utils/BasicBlockUtils.h"
+#include "llvm/Transforms/Utils/Local.h"
 #include "isl/aff.h"
 #include "isl/ast.h"
 #include "isl/ast_build.h"
@@ -293,6 +294,10 @@ void BlockGenerator::copyStmt(ScopStmt &
 
   BasicBlock *BB = Stmt.getBasicBlock();
   copyBB(Stmt, BB, BBMap, LTS, NewAccesses);
+
+  auto CopyBB = Builder.GetInsertBlock();
+  SimplifyInstructionsInBlock(CopyBB, nullptr);
+  Builder.SetInsertPoint(CopyBB->getTerminator());
 }
 
 BasicBlock *BlockGenerator::splitBB(BasicBlock *BB) {

Modified: polly/trunk/test/Isl/CodeGen/MemAccess/codegen_address_space.ll
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/test/Isl/CodeGen/MemAccess/codegen_address_space.ll?rev=248681&r1=248680&r2=248681&view=diff
==============================================================================
--- polly/trunk/test/Isl/CodeGen/MemAccess/codegen_address_space.ll (original)
+++ polly/trunk/test/Isl/CodeGen/MemAccess/codegen_address_space.ll Sun Sep 27 06:17:22 2015
@@ -40,5 +40,4 @@ for.end:
 }
 
 ; CHECK: %polly.access.cast.A = bitcast [100 x i32] addrspace(5)* %A to i32 addrspace(5)*
-; CHECK: %polly.access.A = getelementptr i32, i32 addrspace(5)* %polly.access.cast.A, i64 0
-; CHECK: %tmp2_p_scalar_ = load i32, i32 addrspace(5)* %polly.access.A, align 4, !alias.scope !0, !noalias !2
+; CHECK: %tmp2_p_scalar_ = load i32, i32 addrspace(5)* %polly.access.cast.A, align 4, !alias.scope !0, !noalias !2

Modified: polly/trunk/test/Isl/CodeGen/OpenMP/new_multidim_access.ll
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/test/Isl/CodeGen/OpenMP/new_multidim_access.ll?rev=248681&r1=248680&r2=248681&view=diff
==============================================================================
--- polly/trunk/test/Isl/CodeGen/OpenMP/new_multidim_access.ll (original)
+++ polly/trunk/test/Isl/CodeGen/OpenMP/new_multidim_access.ll Sun Sep 27 06:17:22 2015
@@ -20,14 +20,14 @@
 ; CHECK:    new: [n, m] -> { Stmt_bb4[i0, i1] -> MemRef_A[i0, 43 + i1] };
 
 ; IR: %polly.access.mul.polly.subfunc.arg.A = mul i64 %polly.indvar, %polly.subfunc.arg.m
-; IR: %8 = add nsw i64 %polly.indvar5, 13
-; IR: %polly.access.add.polly.subfunc.arg.A = add i64 %polly.access.mul.polly.subfunc.arg.A, %8
+; IR: %6 = add nsw i64 %polly.indvar5, 13
+; IR: %polly.access.add.polly.subfunc.arg.A = add i64 %polly.access.mul.polly.subfunc.arg.A, %6
 ; IR: %polly.access.polly.subfunc.arg.A = getelementptr float, float* %polly.subfunc.arg.A, i64 %polly.access.add.polly.subfunc.arg.A
 ; IR: %tmp10_p_scalar_ = load float, float* %polly.access.polly.subfunc.arg.A, align 4, !alias.scope !0, !noalias !2, !llvm.mem.parallel_loop_access !3
 
 ; IR: %polly.access.mul.polly.subfunc.arg.A9 = mul i64 %polly.indvar, %polly.subfunc.arg.m
-; IR: %9 = add nsw i64 %polly.indvar5, 43
-; IR: %polly.access.add.polly.subfunc.arg.A10 = add i64 %polly.access.mul.polly.subfunc.arg.A9, %9
+; IR: %7 = add nsw i64 %polly.indvar5, 43
+; IR: %polly.access.add.polly.subfunc.arg.A10 = add i64 %polly.access.mul.polly.subfunc.arg.A9, %7
 ; IR: %polly.access.polly.subfunc.arg.A11 = getelementptr float, float* %polly.subfunc.arg.A, i64 %polly.access.add.polly.subfunc.arg.A10
 ; IR: store float %p_tmp11, float* %polly.access.polly.subfunc.arg.A11, align 4, !alias.scope !0, !noalias !2, !llvm.mem.parallel_
 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"




More information about the llvm-commits mailing list