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 + +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]); +}