Re: [RFC C++ / PR51033 ] Handle __builtin_shuffle in constexpr properly in the C++ frontend.
On Sat, 28 Jul 2012, Marc Glisse wrote: On Mon, 18 Jun 2012, Ramana Radhakrishnan wrote: This patch following on from the fix for turning on __builtin_shuffle for c++ , enables folding of vec_perm_exprs in the front-end for constexpr and constructor style values. Hello, I took a look, and the example I gave in http://gcc.gnu.org/ml/gcc-patches/2012-06/msg01066.html although it doesn't crash the compiler anymore, still fails to compile. I am not sure: were you just trying to remove the ICE, or actually support this use? #include int main(){ constexpr __m128d x={1.,2.}; constexpr __m128i y={1,0}; constexpr __m128d z=__builtin_shuffle(x,y); } $ g++ -std=gnu++11 m.cc m.cc: In function 'int main()': m.cc:5:23: error: '#'vec_perm_expr' not supported by dump_expr#error>' is not a constant expression constexpr __m128d z=__builtin_shuffle(x,y); ^ The issue seems to be that we call fold_ternary_loc with a last argument that is a CONSTRUCTOR whereas the VEC_PERM_EXPR case expects a VECTOR_CST. -- Marc Glisse
Re: [RFC C++ / PR51033 ] Handle __builtin_shuffle in constexpr properly in the C++ frontend.
On 28 July 2012 10:26, Marc Glisse wrote: > On Mon, 18 Jun 2012, Ramana Radhakrishnan wrote: > >> This patch following on from the fix for turning on __builtin_shuffle >> for c++ , enables folding of vec_perm_exprs in the front-end for >> constexpr and constructor style values. > > > Hello, > > I took a look, and the example I gave in > http://gcc.gnu.org/ml/gcc-patches/2012-06/msg01066.html > although it doesn't crash the compiler anymore, still fails to compile. I am > not sure: were you just trying to remove the ICE, or actually support this > use? The intent was to actually support this use properly. I'll have a look but it's unlikely to be today. Ramana > > #include > int main(){ > constexpr __m128d x={1.,2.}; > constexpr __m128i y={1,0}; > constexpr __m128d z=__builtin_shuffle(x,y); > } > > $ g++ -std=gnu++11 m.cc > m.cc: In function 'int main()': > m.cc:5:23: error: '#'vec_perm_expr' not supported by dump_expr# error>' is not a constant expression >constexpr __m128d z=__builtin_shuffle(x,y); >^ > > -- > Marc Glisse
Re: [RFC C++ / PR51033 ] Handle __builtin_shuffle in constexpr properly in the C++ frontend.
On Mon, 18 Jun 2012, Ramana Radhakrishnan wrote: This patch following on from the fix for turning on __builtin_shuffle for c++ , enables folding of vec_perm_exprs in the front-end for constexpr and constructor style values. Hello, I took a look, and the example I gave in http://gcc.gnu.org/ml/gcc-patches/2012-06/msg01066.html although it doesn't crash the compiler anymore, still fails to compile. I am not sure: were you just trying to remove the ICE, or actually support this use? #include int main(){ constexpr __m128d x={1.,2.}; constexpr __m128i y={1,0}; constexpr __m128d z=__builtin_shuffle(x,y); } $ g++ -std=gnu++11 m.cc m.cc: In function 'int main()': m.cc:5:23: error: '#'vec_perm_expr' not supported by dump_expr#error>' is not a constant expression constexpr __m128d z=__builtin_shuffle(x,y); ^ -- Marc Glisse
Re: [RFC C++ / PR51033 ] Handle __builtin_shuffle in constexpr properly in the C++ frontend.
On 25 June 2012 04:32, Jason Merrill wrote: > On 06/18/2012 09:04 AM, Ramana Radhakrishnan wrote: >> >> + location_t loc = EXPR_LOC_OR_HERE (t); > > > We should only use EXPR_LOC_OR_HERE for diagnostics. For a location to use > in building other expressions, use EXPR_LOCATION. Thanks for the review. I've made that change and committed the following patch. Ramana > > OK with that change. > > Jason > committed.patch Description: Binary data
Re: [RFC C++ / PR51033 ] Handle __builtin_shuffle in constexpr properly in the C++ frontend.
On 06/18/2012 09:04 AM, Ramana Radhakrishnan wrote: + location_t loc = EXPR_LOC_OR_HERE (t); We should only use EXPR_LOC_OR_HERE for diagnostics. For a location to use in building other expressions, use EXPR_LOCATION. OK with that change. Jason
Re: [RFC C++ / PR51033 ] Handle __builtin_shuffle in constexpr properly in the C++ frontend.
On 18 June 2012 14:04, Ramana Radhakrishnan wrote: > Hi, > > This patch following on from the fix for turning on __builtin_shuffle > for c++ , enables folding of vec_perm_exprs in the front-end for > constexpr and constructor style values. I was originally going to go > with Marc's patch but then took a look at what it would take to > support this properly which appeared to me to be just calling fold > with the right parameters. > > With simple tests based on variations from c-c++-common/vshuf*.c using > constexpr execution tests appear to pass - There is still an issue > with the compiler giving an error on seeing a subscript operation with > a __builtin_shuffle - I'm going to let that one for someone else to > pick up because I don't have the time to pick this up right at this > minute and the fact is that folks could use an extra vector for the > time being. > > Regression tested with a bootstrap and testrun on powerpc / > x86_64-linux-gnu and cross-tested on arm-linux-gnueabi > > Thoughts ? Ping . Ramana > > regards, > Ramana > > cp/ > > PR C++/51033 > * semantics.c (constexpr_call): Fix typo in comment. > (cxx_eval_vec_perm_expr): New. > (cxx_eval_constant_expression): Fold VEC_PERM_EXPRs. > > testsuite/ > > > * g++.dg/torture/vshuf-16.inc: New test. > * g++.dg/torture/vshuf-2.inc: New test. > * g++.dg/torture/vshuf-4.inc: New test. > * g++.dg/torture/vshuf-8.inc: New test. > * g++.dg/torture/vshuf-main.inc: New test. > * g++.dg/torture/vshuf-v16hi.C: New test. > * g++.dg/torture/vshuf-v16qi.C: New test. > * g++.dg/torture/vshuf-v2df.C: New test. > * g++.dg/torture/vshuf-v2di.C: New test. > * g++.dg/torture/vshuf-v2sf.C: New test. > * g++.dg/torture/vshuf-v2si.C: New test. > * g++.dg/torture/vshuf-v4df.C: New test. > * g++.dg/torture/vshuf-v4di.C: New test. > * g++.dg/torture/vshuf-v4sf.C: New test. > * g++.dg/torture/vshuf-v4si.C: New test. > * g++.dg/torture/vshuf-v8hi.C: New test. > * g++.dg/torture/vshuf-v8qi.C: New test. > * g++.dg/torture/vshuf-v8si.C: New test.