From: Andrew Pinski Date: Sat, 26 Apr 2025 12:49:23 +0000 (-0700) Subject: gimplefe: Round trip of rotates [PR119432] X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=bfc3154375710a37969b2002dc87219dc2102a13;p=thirdparty%2Fgcc.git gimplefe: Round trip of rotates [PR119432] This adds support for rotate left/right to the GIMPLE front-end via __ROTATE_LEFT/__ROTATE_RIGHT oeprators. PR c/119432 gcc/c/ChangeLog: * gimple-parser.cc (gimple_binary_identifier_code): Add __ROTATE_LEFT and __ROTATE_RIGHT. gcc/ChangeLog: * tree-pretty-print.cc (op_symbol_code): For LROTATE_EXPR, output __ROTATE_LEFT for gimple. For RROTATE_EXPR output __ROTATE_RIGHT for gimple. gcc/testsuite/ChangeLog: * gcc.dg/gimplefe-57.c: New test. Signed-off-by: Andrew Pinski --- diff --git a/gcc/c/gimple-parser.cc b/gcc/c/gimple-parser.cc index 34850d7c359..5fd1db87453 100644 --- a/gcc/c/gimple-parser.cc +++ b/gcc/c/gimple-parser.cc @@ -982,6 +982,8 @@ static const std::pair gimple_binary_identifier_code[] {"__FLOOR_MOD", FLOOR_MOD_EXPR}, {"__ROUND_MOD", ROUND_MOD_EXPR}, {"__CEIL_MOD", CEIL_MOD_EXPR}, + {"__ROTATE_LEFT", LROTATE_EXPR}, + {"__ROTATE_RIGHT", RROTATE_EXPR}, }; /* Parse gimple binary expr. diff --git a/gcc/testsuite/gcc.dg/gimplefe-57.c b/gcc/testsuite/gcc.dg/gimplefe-57.c new file mode 100644 index 00000000000..d3eca56119d --- /dev/null +++ b/gcc/testsuite/gcc.dg/gimplefe-57.c @@ -0,0 +1,11 @@ +/* { dg-do compile } */ +/* { dg-options "-fgimple" } */ + +int __GIMPLE +foo (int a, int b) +{ + int tem; + tem = a __ROTATE_LEFT b; + tem = tem __ROTATE_RIGHT b; + return tem; +} diff --git a/gcc/tree-pretty-print.cc b/gcc/tree-pretty-print.cc index c1a21e77bd2..359359d98c2 100644 --- a/gcc/tree-pretty-print.cc +++ b/gcc/tree-pretty-print.cc @@ -4795,10 +4795,10 @@ op_symbol_code (enum tree_code code, dump_flags_t flags) return ">>"; case LROTATE_EXPR: - return "r<<"; + return (flags & TDF_GIMPLE) ? "__ROTATE_LEFT" : "r<<"; case RROTATE_EXPR: - return "r>>"; + return (flags & TDF_GIMPLE) ? "__ROTATE_RIGHT" : "r>>"; case WIDEN_LSHIFT_EXPR: return "w<<";