]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
gimplefe: Round trip of rotates [PR119432]
authorAndrew Pinski <quic_apinski@quicinc.com>
Sat, 26 Apr 2025 12:49:23 +0000 (05:49 -0700)
committerAndrew Pinski <quic_apinski@quicinc.com>
Mon, 28 Apr 2025 17:14:14 +0000 (10:14 -0700)
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 <quic_apinski@quicinc.com>
gcc/c/gimple-parser.cc
gcc/testsuite/gcc.dg/gimplefe-57.c [new file with mode: 0644]
gcc/tree-pretty-print.cc

index 34850d7c359fc4f7d3ca03e7977c4ca9e663605c..5fd1db874530b9ae120d5e5b469614c0aecd40b6 100644 (file)
@@ -982,6 +982,8 @@ static const std::pair<const char *, tree_code> 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 (file)
index 0000000..d3eca56
--- /dev/null
@@ -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;
+}
index c1a21e77bd297e36a2e53e04fd34fdf7b802bb22..359359d98c20c7a3bf16e7eab715403eba347795 100644 (file)
@@ -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<<";