""
"%.\\tshr.u%T0\\t%0, %1, %2;")
+(define_insn "rotlsi3"
+ [(set (match_operand:SI 0 "nvptx_register_operand" "=R")
+ (rotate:SI (match_operand:SI 1 "nvptx_register_operand" "R")
+ (and:SI (match_operand:SI 2 "nvptx_nonmemory_operand" "Ri")
+ (const_int 31))))]
+ "TARGET_SM35"
+ "%.\\tshf.l.wrap.b32\\t%0, %1, %1, %2;")
+
+(define_insn "rotrsi3"
+ [(set (match_operand:SI 0 "nvptx_register_operand" "=R")
+ (rotatert:SI (match_operand:SI 1 "nvptx_register_operand" "R")
+ (and:SI (match_operand:SI 2 "nvptx_nonmemory_operand" "Ri")
+ (const_int 31))))]
+ "TARGET_SM35"
+ "%.\\tshf.r.wrap.b32\\t%0, %1, %1, %2;")
+
;; Logical operations
(define_code_iterator any_logic [and ior xor])
--- /dev/null
+/* { dg-do run } */
+/* { dg-options "-O2" } */
+
+#include "rotate.c"
+
+#define ASSERT(EXPR) \
+ do \
+ { \
+ if (!(EXPR)) \
+ __builtin_abort (); \
+ } while (0)
+
+int
+main (void)
+{
+ ASSERT (rotl (0x12345678, 8) == 0x34567812);
+ ASSERT (rotl (0x12345678, 8 + 32) == 0x34567812);
+
+ ASSERT (rotr (0x12345678, 8) == 0x78123456);
+ ASSERT (rotr (0x12345678, 8 + 32) == 0x78123456);
+
+ return 0;
+}
--- /dev/null
+/* { dg-do assemble } */
+/* { dg-options "-O2 -save-temps" } */
+
+#define MASK 0x1f
+
+unsigned int
+rotl (unsigned int val, unsigned int cnt) {
+ cnt &= MASK;
+ return (val << cnt) | (val >> (-cnt & MASK));
+}
+
+unsigned int
+rotr (unsigned int val, unsigned int cnt) {
+ cnt &= MASK;
+ return (val >> cnt) | (val << (-cnt & MASK));
+}
+
+/* { dg-final { scan-assembler-times "shf.l.wrap.b32" 1 } } */
+/* { dg-final { scan-assembler-times "shf.r.wrap.b32" 1 } } */
+/* { dg-final { scan-assembler-not "and.b32" } } */