asbirlea updated this revision to Diff 198560. asbirlea added a comment. Herald added a subscriber: zzheng.
Added test. Last RUN line fails before this patch (i.e. unrolling is not disabled with the given flag in the new pass manager). Repository: rC Clang CHANGES SINCE LAST ACTION https://reviews.llvm.org/D61620/new/ https://reviews.llvm.org/D61620 Files: lib/CodeGen/BackendUtil.cpp test/CodeGenCXX/no-pragma-loop-unroll.cpp Index: test/CodeGenCXX/no-pragma-loop-unroll.cpp =================================================================== --- /dev/null +++ test/CodeGenCXX/no-pragma-loop-unroll.cpp @@ -0,0 +1,31 @@ +// RUN: %clang -S -c -O1 -funroll-loops -std=c++11 -emit-llvm -o - %s | FileCheck %s -check-prefix=CHECK-ENABLE-UNROLL +// RUN: %clang -S -c -O1 -fno-unroll-loops -std=c++11 -emit-llvm -o - %s | FileCheck %s -check-prefix=CHECK-DISABLE-UNROLL +// RUN: %clang -fexperimental-new-pass-manager -S -c -O1 -funroll-loops -std=c++11 -emit-llvm -o - %s | FileCheck %s -check-prefix=CHECK-ENABLE-UNROLL +// RUN: %clang -fexperimental-new-pass-manager -S -c -O1 -fno-unroll-loops -std=c++11 -emit-llvm -o - %s | FileCheck %s -check-prefix=CHECK-DISABLE-UNROLL + +// CHECK-ENABLE-UNROLL: for.body: +// CHECK-ENABLE-UNROLL: store +// CHECK-ENABLE-UNROLL: store +// CHECK-ENABLE-UNROLL: for.body5: + +// CHECK-DISABLE-UNROLL: for.body: +// CHECK-DISABLE-UNROLL: store +// CHECK-DISABLE-UNROLL-NOT: store +// CHECK-DISABLE-UNROLL: for.body5: + +#include <stdio.h> + +void for_test() { + double A[1000], B[1000]; + int L = 500; + for (int i = 0; i < L; i++) { + A[i] = i; + } + for (int i = 0; i < L; i++) { + B[i] = A[i]*5; + B[i]++; + A[i] *= 7; + A[i]++; + } + printf("%lf %lf\n", A[0], B[0]); +} Index: lib/CodeGen/BackendUtil.cpp =================================================================== --- lib/CodeGen/BackendUtil.cpp +++ lib/CodeGen/BackendUtil.cpp @@ -1026,6 +1026,7 @@ } PipelineTuningOptions PTO; + PTO.LoopUnrolling = CodeGenOpts.UnrollLoops; // For historical reasons, loop interleaving is set to mirror setting for loop // unrolling. PTO.LoopInterleaving = CodeGenOpts.UnrollLoops;
Index: test/CodeGenCXX/no-pragma-loop-unroll.cpp =================================================================== --- /dev/null +++ test/CodeGenCXX/no-pragma-loop-unroll.cpp @@ -0,0 +1,31 @@ +// RUN: %clang -S -c -O1 -funroll-loops -std=c++11 -emit-llvm -o - %s | FileCheck %s -check-prefix=CHECK-ENABLE-UNROLL +// RUN: %clang -S -c -O1 -fno-unroll-loops -std=c++11 -emit-llvm -o - %s | FileCheck %s -check-prefix=CHECK-DISABLE-UNROLL +// RUN: %clang -fexperimental-new-pass-manager -S -c -O1 -funroll-loops -std=c++11 -emit-llvm -o - %s | FileCheck %s -check-prefix=CHECK-ENABLE-UNROLL +// RUN: %clang -fexperimental-new-pass-manager -S -c -O1 -fno-unroll-loops -std=c++11 -emit-llvm -o - %s | FileCheck %s -check-prefix=CHECK-DISABLE-UNROLL + +// CHECK-ENABLE-UNROLL: for.body: +// CHECK-ENABLE-UNROLL: store +// CHECK-ENABLE-UNROLL: store +// CHECK-ENABLE-UNROLL: for.body5: + +// CHECK-DISABLE-UNROLL: for.body: +// CHECK-DISABLE-UNROLL: store +// CHECK-DISABLE-UNROLL-NOT: store +// CHECK-DISABLE-UNROLL: for.body5: + +#include <stdio.h> + +void for_test() { + double A[1000], B[1000]; + int L = 500; + for (int i = 0; i < L; i++) { + A[i] = i; + } + for (int i = 0; i < L; i++) { + B[i] = A[i]*5; + B[i]++; + A[i] *= 7; + A[i]++; + } + printf("%lf %lf\n", A[0], B[0]); +} Index: lib/CodeGen/BackendUtil.cpp =================================================================== --- lib/CodeGen/BackendUtil.cpp +++ lib/CodeGen/BackendUtil.cpp @@ -1026,6 +1026,7 @@ } PipelineTuningOptions PTO; + PTO.LoopUnrolling = CodeGenOpts.UnrollLoops; // For historical reasons, loop interleaving is set to mirror setting for loop // unrolling. PTO.LoopInterleaving = CodeGenOpts.UnrollLoops;
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits