Skip to content

Commit da33d80

Browse files
committedJul 10, 2015
Disable loop re-rotation for -Oz (patch by Andrey Turetsky)
After changes in rL231820 loop re-rotation is performed even in -Oz mode. Since loop rotation is disabled for -Oz, it seems loop re-rotation should be disabled too. Differential Revision: http://reviews.llvm.org/D10961 llvm-svn: 241897
1 parent edb0210 commit da33d80

File tree

2 files changed

+32
-2
lines changed

2 files changed

+32
-2
lines changed
 

‎llvm/lib/Transforms/IPO/PassManagerBuilder.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -320,8 +320,8 @@ void PassManagerBuilder::populateModulePassManager(
320320

321321
// Re-rotate loops in all our loop nests. These may have fallout out of
322322
// rotated form due to GVN or other transformations, and the vectorizer relies
323-
// on the rotated form.
324-
MPM.add(createLoopRotatePass());
323+
// on the rotated form. Disable header duplication at -Oz.
324+
MPM.add(createLoopRotatePass(SizeLevel == 2 ? 0 : -1));
325325

326326
// Distribute loops to allow partial vectorization. I.e. isolate dependences
327327
// into separate loop that would otherwise inhibit vectorization.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
; REQUIRES: asserts
2+
; RUN: opt < %s -S -Os -debug -debug-only=loop-rotate 2>&1 | FileCheck %s -check-prefix=OS
3+
; RUN: opt < %s -S -Oz -debug -debug-only=loop-rotate 2>&1 | FileCheck %s -check-prefix=OZ
4+
5+
; Loop should be rotated for -Os but not for -Oz.
6+
; OS: rotating Loop at depth 1
7+
; OZ-NOT: rotating Loop at depth 1
8+
9+
@e = global i32 10
10+
11+
declare void @use(i32)
12+
13+
define void @test() {
14+
entry:
15+
%end = load i32, i32* @e
16+
br label %loop
17+
18+
loop:
19+
%n.phi = phi i32 [ %n, %loop.fin ], [ 0, %entry ]
20+
%cond = icmp eq i32 %n.phi, %end
21+
br i1 %cond, label %exit, label %loop.fin
22+
23+
loop.fin:
24+
%n = add i32 %n.phi, 1
25+
call void @use(i32 %n)
26+
br label %loop
27+
28+
exit:
29+
ret void
30+
}

0 commit comments

Comments
 (0)
Please sign in to comment.