[llvm] r268121 - [MBP] Use Function::optForSize() instead of checking OptimizeForSize directly.
Haicheng Wu via llvm-commits
llvm-commits at lists.llvm.org
Fri Apr 29 15:01:10 PDT 2016
Author: haicheng
Date: Fri Apr 29 17:01:10 2016
New Revision: 268121
URL: http://llvm.org/viewvc/llvm-project?rev=268121&view=rev
Log:
[MBP] Use Function::optForSize() instead of checking OptimizeForSize directly.
Fix a FIXME. Disable loop alignment if compiled with -Oz now.
Modified:
llvm/trunk/lib/CodeGen/MachineBlockPlacement.cpp
llvm/trunk/test/CodeGen/PowerPC/code-align.ll
llvm/trunk/test/CodeGen/X86/loop-blocks.ll
Modified: llvm/trunk/lib/CodeGen/MachineBlockPlacement.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/MachineBlockPlacement.cpp?rev=268121&r1=268120&r2=268121&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/MachineBlockPlacement.cpp (original)
+++ llvm/trunk/lib/CodeGen/MachineBlockPlacement.cpp Fri Apr 29 17:01:10 2016
@@ -1366,8 +1366,7 @@ void MachineBlockPlacement::alignBlocks(
// exclusively on the loop info here so that we can align backedges in
// unnatural CFGs and backedges that were introduced purely because of the
// loop rotations done during this layout pass.
- // FIXME: Use Function::optForSize().
- if (F.getFunction()->hasFnAttribute(Attribute::OptimizeForSize))
+ if (F.getFunction()->optForSize())
return;
BlockChain &FunctionChain = *BlockToChain[&F.front()];
if (FunctionChain.begin() == FunctionChain.end())
Modified: llvm/trunk/test/CodeGen/PowerPC/code-align.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/PowerPC/code-align.ll?rev=268121&r1=268120&r2=268121&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/PowerPC/code-align.ll (original)
+++ llvm/trunk/test/CodeGen/PowerPC/code-align.ll Fri Apr 29 17:01:10 2016
@@ -105,6 +105,48 @@ for.end:
ret void
}
+; Function Attrs: nounwind
+define void @test_minsize(i32 signext %x, i32* nocapture %a) #2 {
+entry:
+ br label %vector.body
+
+; GENERIC-LABEL: @test_minsize
+; BASIC-LABEL: @test_minsize
+; PWR-LABEL: @test_minsize
+; GENERIC: mtctr
+; BASIC: mtctr
+; PWR: mtctr
+; GENERIC-NOT: .p2align
+; BASIC-NOT: .p2align
+; PWR-NOT: .p2align
+; GENERIC: lwzu
+; BASIC: lwzu
+; PWR: lwzu
+; GENERIC: bdnz
+; BASIC: bdnz
+; PWR: bdnz
+
+vector.body: ; preds = %vector.body, %entry
+ %index = phi i64 [ 0, %entry ], [ %index.next, %vector.body ]
+ %induction45 = or i64 %index, 1
+ %0 = getelementptr inbounds i32, i32* %a, i64 %index
+ %1 = getelementptr inbounds i32, i32* %a, i64 %induction45
+ %2 = load i32, i32* %0, align 4
+ %3 = load i32, i32* %1, align 4
+ %4 = add nsw i32 %2, 4
+ %5 = add nsw i32 %3, 4
+ %6 = mul nsw i32 %4, 3
+ %7 = mul nsw i32 %5, 3
+ store i32 %6, i32* %0, align 4
+ store i32 %7, i32* %1, align 4
+ %index.next = add i64 %index, 2
+ %8 = icmp eq i64 %index.next, 2048
+ br i1 %8, label %for.end, label %vector.body
+
+for.end: ; preds = %vector.body
+ ret void
+}
attributes #0 = { nounwind readnone }
attributes #1 = { nounwind }
+attributes #2 = { nounwind minsize}
Modified: llvm/trunk/test/CodeGen/X86/loop-blocks.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/loop-blocks.ll?rev=268121&r1=268120&r2=268121&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/X86/loop-blocks.ll (original)
+++ llvm/trunk/test/CodeGen/X86/loop-blocks.ll Fri Apr 29 17:01:10 2016
@@ -200,6 +200,34 @@ block102:
br label %loop
}
+; CHECK-LABEL: check_minsize:
+; CHECK: jmp .LBB4_1
+; CHECK-NOT: align
+; CHECK-NEXT: .LBB4_2:
+; CHECK-NEXT: callq loop_latch
+; CHECK-NEXT: .LBB4_1:
+; CHECK-NEXT: callq loop_header
+
+
+define void @check_minsize() minsize nounwind {
+entry:
+ br label %loop
+
+loop:
+ call void @loop_header()
+ %t0 = tail call i32 @get()
+ %t1 = icmp slt i32 %t0, 0
+ br i1 %t1, label %done, label %bb
+
+bb:
+ call void @loop_latch()
+ br label %loop
+
+done:
+ call void @exit()
+ ret void
+}
+
declare void @bar99() nounwind
declare void @bar100() nounwind
declare void @bar101() nounwind
More information about the llvm-commits
mailing list