
Summary: The old pass manager separated speed optimization and size optimization levels into two unsigned values. Coallescing both in an enum in the new pass manager may lead to unintentional casts and comparisons. In particular, taking a look at how the loop unroll passes were constructed previously, the Os/Oz are now (==new pass manager) treated just like O3, likely unintentionally. This change disallows raw comparisons between optimization levels, to avoid such unintended effects. As an effect, the O{s|z} behavior changes for loop unrolling and loop unroll and jam, matching O2 rather than O3. The change also parameterizes the threshold values used for loop unrolling, primarily to aid testing. Reviewers: tejohnson, davidxl Reviewed By: tejohnson Subscribers: zzheng, ychen, mehdi_amini, hiraditya, steven_wu, dexonsmith, dang, cfe-commits, llvm-commits Tags: #clang, #llvm Differential Revision: https://reviews.llvm.org/D72547
48 lines
1.7 KiB
LLVM
48 lines
1.7 KiB
LLVM
; RUN: opt < %s -S -passes="default<O2>" -unroll-runtime=true -unroll-threshold-default=0 -unroll-threshold-aggressive=300 | FileCheck %s -check-prefix=O2
|
|
; RUN: opt < %s -S -passes="default<O3>" -unroll-runtime=true -unroll-threshold-default=0 -unroll-threshold-aggressive=300 | FileCheck %s -check-prefix=O3
|
|
; RUN: opt < %s -S -passes="default<Os>" -unroll-runtime=true -unroll-threshold-default=0 -unroll-threshold-aggressive=300 | FileCheck %s -check-prefix=Os
|
|
; RUN: opt < %s -S -passes="default<Oz>" -unroll-runtime=true -unroll-threshold-default=0 -unroll-threshold-aggressive=300 | FileCheck %s -check-prefix=Oz
|
|
|
|
; Check that Os and Oz are optimized like O2, not like O3. To easily highlight
|
|
; the behavior, we artificially disable unrolling for anything but O3 by setting
|
|
; the default threshold to 0.
|
|
|
|
; O3: loop2.preheader
|
|
; O2-NOT: loop2.preheader
|
|
; Os-NOT: loop2.preheader
|
|
; Oz-NOT: loop2.preheader
|
|
|
|
define void @unroll(i32 %iter, i32* %addr1, i32* %addr2) nounwind {
|
|
entry:
|
|
br label %loop1
|
|
|
|
loop1:
|
|
%iv1 = phi i32 [ 0, %entry ], [ %inc1, %loop1.latch ]
|
|
%offset1 = getelementptr i32, i32* %addr1, i32 %iv1
|
|
store i32 %iv1, i32* %offset1, align 4
|
|
br label %loop2.header
|
|
|
|
loop2.header:
|
|
%e = icmp uge i32 %iter, 1
|
|
br i1 %e, label %loop2, label %exit2
|
|
|
|
loop2:
|
|
%iv2 = phi i32 [ 0, %loop2.header ], [ %inc2, %loop2 ]
|
|
%offset2 = getelementptr i32, i32* %addr2, i32 %iv2
|
|
store i32 %iv2, i32* %offset2, align 4
|
|
%inc2 = add i32 %iv2, 1
|
|
%exitcnd2 = icmp uge i32 %inc2, %iter
|
|
br i1 %exitcnd2, label %exit2, label %loop2
|
|
|
|
exit2:
|
|
br label %loop1.latch
|
|
|
|
loop1.latch:
|
|
%inc1 = add i32 %iv1, 1
|
|
%exitcnd1 = icmp uge i32 %inc1, 1024
|
|
br i1 %exitcnd1, label %exit, label %loop1
|
|
|
|
exit:
|
|
ret void
|
|
}
|