@@ -2898,32 +2898,15 @@ static bool checkWorkGroupSizeValues(Sema &S, Decl *D, const ParsedAttr &Attr,
28982898 /* ReverseAttrs=*/ true );
28992899
29002900 if (const auto *A = D->getAttr <SYCLIntelMaxWorkGroupSizeAttr>()) {
2901- if (S.getLangOpts ().SYCLIsDevice &&
2902- !(WGSize[2 ] <= A->getXDim () && WGSize[1 ] <= A->getYDim () &&
2903- WGSize[0 ] <= A->getZDim ())) {
2904- S.Diag (Attr.getLoc (), diag::err_conflicting_sycl_function_attributes)
2905- << Attr << A->getSpelling ();
2906- Result &= false ;
2907- }
2908- if (!S.getLangOpts ().SYCLIsDevice &&
2909- !(WGSize[0 ] <= A->getXDim () && WGSize[1 ] <= A->getYDim () &&
2901+ if (!(WGSize[0 ] <= A->getXDim () && WGSize[1 ] <= A->getYDim () &&
29102902 WGSize[2 ] <= A->getZDim ())) {
29112903 S.Diag (Attr.getLoc (), diag::err_conflicting_sycl_function_attributes)
29122904 << Attr << A->getSpelling ();
29132905 Result &= false ;
29142906 }
29152907 }
29162908 if (const auto *A = D->getAttr <ReqdWorkGroupSizeAttr>()) {
2917-
2918- if (S.getLangOpts ().SYCLIsDevice &&
2919- !(WGSize[2 ] >= A->getXDim () && WGSize[1 ] >= A->getYDim () &&
2920- WGSize[0 ] >= A->getZDim ())) {
2921- S.Diag (Attr.getLoc (), diag::err_conflicting_sycl_function_attributes)
2922- << Attr << A->getSpelling ();
2923- Result &= false ;
2924- }
2925- if (!S.getLangOpts ().SYCLIsDevice &&
2926- !(WGSize[0 ] >= A->getXDim () && WGSize[1 ] >= A->getYDim () &&
2909+ if (!(WGSize[0 ] >= A->getXDim () && WGSize[1 ] >= A->getYDim () &&
29272910 WGSize[2 ] >= A->getZDim ())) {
29282911 S.Diag (Attr.getLoc (), diag::err_conflicting_sycl_function_attributes)
29292912 << Attr << A->getSpelling ();
@@ -2940,13 +2923,9 @@ static void handleWorkGroupSize(Sema &S, Decl *D, const ParsedAttr &AL) {
29402923 return ;
29412924
29422925 uint32_t WGSize[3 ];
2943- if (const auto *A = D->getAttr <SYCLIntelReqdWorkGroupSizeAttr>()){
2944- WGSize[1 ] = SYCLIntelReqdWorkGroupSizeAttr::DefaultYDim;
2945- WGSize[2 ] = SYCLIntelReqdWorkGroupSizeAttr::DefaultZDim;
2946- }
29472926 for (unsigned i = 0 ; i < 3 ; ++i) {
29482927 const Expr *E = AL.getArgAsExpr (i);
2949- if (i < AL. getNumArgs () && !checkUInt32Argument (S, AL, E, WGSize[i], i,
2928+ if (!checkUInt32Argument (S, AL, E, WGSize[i], i,
29502929 /* StrictlyUnsigned=*/ true ))
29512930 return ;
29522931 if (WGSize[i] == 0 ) {
@@ -2956,25 +2935,20 @@ static void handleWorkGroupSize(Sema &S, Decl *D, const ParsedAttr &AL) {
29562935 }
29572936 }
29582937
2938+ // For a SYCLDevice WorkGroupAttr arguments are reversed
2939+ if (S.getLangOpts ().SYCLIsDevice ) {
2940+ std::swap (WGSize[0 ], WGSize[2 ]);
2941+ }
29592942 WorkGroupAttr *Existing = D->getAttr <WorkGroupAttr>();
2960- if (S.getLangOpts ().SYCLIsDevice && Existing &&
2961- !(Existing->getXDim () == WGSize[2 ] && Existing->getYDim () == WGSize[1 ] &&
2962- Existing->getZDim () == WGSize[0 ]))
2963- S.Diag (AL.getLoc (), diag::warn_duplicate_attribute) << AL;
2964- if (!S.getLangOpts ().SYCLIsDevice && Existing &&
2943+ if (Existing &&
29652944 !(Existing->getXDim () == WGSize[0 ] && Existing->getYDim () == WGSize[1 ] &&
29662945 Existing->getZDim () == WGSize[2 ]))
29672946 S.Diag (AL.getLoc (), diag::warn_duplicate_attribute) << AL;
2968-
29692947 if (!checkWorkGroupSizeValues (S, D, AL, WGSize))
29702948 return ;
29712949
2972- if (S.getLangOpts ().SYCLIsDevice )
2973- D->addAttr (::new (S.Context ) WorkGroupAttr (S.Context , AL, WGSize[2 ],
2974- WGSize[1 ], WGSize[0 ]));
2975- else
2976- D->addAttr (::new (S.Context ) WorkGroupAttr (S.Context , AL, WGSize[0 ],
2977- WGSize[1 ], WGSize[2 ]));
2950+ D->addAttr (::new (S.Context )
2951+ WorkGroupAttr (S.Context , AL, WGSize[0 ], WGSize[1 ], WGSize[2 ]));
29782952}
29792953
29802954// Handles intel_reqd_sub_group_size.
0 commit comments