-
Notifications
You must be signed in to change notification settings - Fork 15.4k
[flang] Add -f[no-]unroll-loops flag #122906
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
c9b2e58
d66a7c6
ac03aad
f27462b
0141e0d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -150,12 +150,17 @@ void Flang::addCodegenOptions(const ArgList &Args, | |
| if (shouldLoopVersion(Args)) | ||
| CmdArgs.push_back("-fversion-loops-for-stride"); | ||
|
|
||
| Args.addAllArgs(CmdArgs, {options::OPT_flang_experimental_hlfir, | ||
| options::OPT_flang_deprecated_no_hlfir, | ||
| options::OPT_fno_ppc_native_vec_elem_order, | ||
| options::OPT_fppc_native_vec_elem_order}); | ||
| Args.addAllArgs(CmdArgs, | ||
| {options::OPT_flang_experimental_hlfir, | ||
| options::OPT_flang_deprecated_no_hlfir, | ||
| options::OPT_fno_ppc_native_vec_elem_order, | ||
| options::OPT_fppc_native_vec_elem_order, | ||
| options::OPT_ftime_report, options::OPT_ftime_report_EQ}); | ||
| options::OPT_ftime_report, options::OPT_ftime_report_EQ, | ||
| options::OPT_funroll_loops, options::OPT_fno_unroll_loops}); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We can add a forwarding test from the driver to the frontend driver. |
||
| } | ||
|
|
||
| void Flang::addPicOptions(const ArgList &Args, ArgStringList &CmdArgs) const { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| // RUN: %flang_fc1 -emit-llvm -O1 -funroll-loops -mllvm -force-vector-width=1 -o- %s | FileCheck %s --check-prefixes=CHECK,UNROLL | ||
|
||
| // RUN: %flang_fc1 -emit-llvm -O2 -mllvm -force-vector-width=1 -o- %s | FileCheck %s --check-prefixes=CHECK,UNROLL | ||
| // RUN: %flang_fc1 -emit-llvm -O1 -fno-unroll-loops -mllvm -force-vector-width=1 -o- %s | FileCheck %s --check-prefixes=CHECK,NO-UNROLL | ||
| // RUN: %flang_fc1 -emit-llvm -O1 -mllvm -force-vector-width=1 -o- %s | FileCheck %s --check-prefixes=CHECK,NO-UNROLL | ||
|
|
||
| // CHECK-LABEL: @unroll | ||
| // CHECK-SAME: (ptr nocapture writeonly %[[ARG0:.*]]) | ||
| func.func @unroll(%arg0: !fir.ref<!fir.array<1000xf64>> {fir.bindc_name = "a"}) { | ||
| // CHECK: %[[GEPIV:.*]] = getelementptr i8, ptr %0, i64 -8 | ||
| %scope = fir.dummy_scope : !fir.dscope | ||
| %c1000 = arith.constant 1000 : index | ||
| %shape = fir.shape %c1000 : (index) -> !fir.shape<1> | ||
| %a:2 = hlfir.declare %arg0(%shape) dummy_scope %scope {uniq_name = "unrollEa"} : (!fir.ref<!fir.array<1000xf64>>, !fir.shape<1>, !fir.dscope) -> (!fir.ref<!fir.array<1000xf64>>, !fir.ref<!fir.array<1000xf64>>) | ||
| %c1 = arith.constant 1 : index | ||
| fir.do_loop %arg1 = %c1 to %c1000 step %c1 { | ||
| // CHECK: [[BLK:.*]]: | ||
|
|
||
| // NO-UNROLL-NEXT: %[[PHI:.*]] = phi i64 [ 1, %{{.*}} ], [ %[[NIV:.*]], %[[BLK]] ] | ||
| // NO-UNROLL-NEXT: %[[IV_D:.*]] = uitofp nneg i64 %[[PHI]] to double | ||
| // NO-UNROLL-NEXT: %[[GEP:.*]] = getelementptr double, ptr %[[GEPIV]], i64 %[[PHI]] | ||
| // NO-UNROLL-NEXT: store double %[[IV_D]], ptr %[[GEP]] | ||
| // NO-UNROLL-NEXT: %[[NIV:.*]] = add nuw nsw i64 %{{.*}}, 1 | ||
| // NO-UNROLL-NEXT: %[[EXIT:.*]] = icmp eq i64 %[[NIV]], 1001 | ||
| // NO-UNROLL-NEXT: br i1 %[[EXIT]], label %{{.*}}, label %[[BLK]] | ||
|
|
||
| // UNROLL-NEXT: %[[PHI:.*]] = phi i64 [ 0, %{{.*}} ], [ %[[NIV:.*]], %[[BLK]] ] | ||
| // UNROLL-NEXT: %[[IV0:.*]] = or disjoint i64 %[[PHI]], 1 | ||
| // UNROLL-NEXT: %[[IV1:.*]] = add i64 %[[PHI]], 2 | ||
| // UNROLL-NEXT: %[[IV0_D:.*]] = uitofp nneg i64 %[[IV0]] to double | ||
| // UNROLL-NEXT: %[[IV1_D:.*]] = uitofp nneg i64 %[[IV1]] to double | ||
| // UNROLL-NEXT: %[[GEP0:.*]] = getelementptr double, ptr %[[ARG0]], i64 %[[PHI]] | ||
| // UNROLL-NEXT: %[[GEP1:.*]] = getelementptr double, ptr %[[GEPIV]], i64 %[[IV1]] | ||
| // UNROLL-NEXT: store double %[[IV0_D]], ptr %[[GEP0]] | ||
| // UNROLL-NEXT: store double %[[IV1_D]], ptr %[[GEP1]] | ||
| // UNROLL-NEXT: %[[NIV:.*]] = add nuw i64 %[[PHI]], 2 | ||
| // UNROLL-NEXT: %[[EXIT:.*]] = icmp eq i64 %[[NIV]], 1000 | ||
| // UNROLL-NEXT: br i1 %[[EXIT]], label %{{.*}}, label %[[BLK]] | ||
| %iv = fir.convert %arg1 : (index) -> f64 | ||
| %ai = hlfir.designate %a#0 (%arg1) : (!fir.ref<!fir.array<1000xf64>>, index) -> !fir.ref<f64> | ||
| hlfir.assign %iv to %ai : f64, !fir.ref<f64> | ||
| } | ||
| return | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this added separately from below?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bad rebase I think 😓