Index: clang/lib/CodeGen/CGOpenMPRuntime.cpp =================================================================== --- clang/lib/CodeGen/CGOpenMPRuntime.cpp +++ clang/lib/CodeGen/CGOpenMPRuntime.cpp @@ -11506,7 +11506,9 @@ ParamAttr.Kind == LinearUVal || ParamAttr.Kind == LinearVal) { // Don't print the step value if it is not present or if it is // equal to 1. - if (ParamAttr.StrideOrArg != 1) + if (ParamAttr.StrideOrArg < 0) + Out << 'n' << -ParamAttr.StrideOrArg; + else if (ParamAttr.StrideOrArg != 1) Out << ParamAttr.StrideOrArg; } Index: clang/test/OpenMP/declare_simd_codegen.cpp =================================================================== --- clang/test/OpenMP/declare_simd_codegen.cpp +++ clang/test/OpenMP/declare_simd_codegen.cpp @@ -155,6 +155,14 @@ return a + int(b); } +// Test negative strides +#pragma omp declare simd simdlen(4) linear(a:-2) linear(b:-8) \ + linear(uval(c):-4) linear(ref(d):-16) \ + linear(e:-1) linear(f:-1) linear(g:0) +double Six(int a, float *b, int &c, int *&d, char e, char *f, short g) { + return a + int(*b) + c + *d + e + *f + g; +} + // CHECK-DAG: define {{.+}}@_Z5add_1Pf( // CHECK-DAG: define {{.+}}@_Z1hIiEvPT_S1_S1_S1_( // CHECK-DAG: define {{.+}}@_Z1hIfEvPT_S1_S1_S1_( @@ -178,6 +186,7 @@ // CHECK-DAG: define {{.+}}@_Z5ThreeRiS_ // CHECK-DAG: define {{.+}}@_Z4FourRiS_ // CHECK-DAG: define {{.+}}@_Z4FiveiRsS_S_S_S_S_S_S_ +// CHECK-DAG: define {{.+}}@_Z3SixiPfRiRPicPcs // CHECK-DAG: "_ZGVbM4l32__Z5add_1Pf" // CHECK-DAG: "_ZGVbN4l32__Z5add_1Pf" @@ -399,6 +408,8 @@ // CHECK-DAG: "_ZGVbN4R8R4__Z4FourRiS_" // CHECK-DAG: "_ZGVbM4uL2Ls0L4Ls0U8Us0R32Rs0__Z4FiveiRsS_S_S_S_S_S_S_" // CHECK-DAG: "_ZGVbN4uL2Ls0L4Ls0U8Us0R32Rs0__Z4FiveiRsS_S_S_S_S_S_S_" +// CHECK-DAG: "_ZGVbM4ln2ln32Un4Rn128ln1ln1l0__Z3SixiPfRiRPicPcs" +// CHECK-DAG: "_ZGVbN4ln2ln32Un4Rn128ln1ln1l0__Z3SixiPfRiRPicPcs" // CHECK-NOT: "_ZGV{{.+}}__Z1fRA_i