DONE;
})
+(define_insn "popcount<mode>2"
+ [(set (match_operand:SI 0 "nvptx_register_operand" "=R")
+ (popcount:SI (match_operand:SDIM 1 "nvptx_register_operand" "R")))]
+ ""
+ "%.\\tpopc.b%T1\\t%0, %1;")
+
+;; Multiplication variants
+
+(define_insn "mulhisi3"
+ [(set (match_operand:SI 0 "nvptx_register_operand" "=R")
+ (mult:SI (sign_extend:SI
+ (match_operand:HI 1 "nvptx_register_operand" "R"))
+ (sign_extend:SI
+ (match_operand:HI 2 "nvptx_register_operand" "R"))))]
+ ""
+ "%.\\tmul.wide.s16\\t%0, %1, %2;")
+
+(define_insn "mulsidi3"
+ [(set (match_operand:DI 0 "nvptx_register_operand" "=R")
+ (mult:DI (sign_extend:DI
+ (match_operand:SI 1 "nvptx_register_operand" "R"))
+ (sign_extend:DI
+ (match_operand:SI 2 "nvptx_register_operand" "R"))))]
+ ""
+ "%.\\tmul.wide.s32\\t%0, %1, %2;")
+
+(define_insn "umulhisi3"
+ [(set (match_operand:SI 0 "nvptx_register_operand" "=R")
+ (mult:SI (zero_extend:SI
+ (match_operand:HI 1 "nvptx_register_operand" "R"))
+ (zero_extend:SI
+ (match_operand:HI 2 "nvptx_register_operand" "R"))))]
+ ""
+ "%.\\tmul.wide.u16\\t%0, %1, %2;")
+
+(define_insn "umulsidi3"
+ [(set (match_operand:DI 0 "nvptx_register_operand" "=R")
+ (mult:DI (zero_extend:DI
+ (match_operand:SI 1 "nvptx_register_operand" "R"))
+ (zero_extend:DI
+ (match_operand:SI 2 "nvptx_register_operand" "R"))))]
+ ""
+ "%.\\tmul.wide.u32\\t%0, %1, %2;")
+
;; Shifts
(define_insn "ashl<mode>3"
--- /dev/null
+/* { dg-do compile } */
+/* { dg-options "-O2" } */
+
+int mulhisi3(short x, short y)
+{
+ return (int)x * (int)y;
+}
+
+long mulsidi3(int x, int y)
+{
+ return (long)x * (long)y;
+}
+
+/* { dg-final { scan-assembler-times "mul.wide.s16" 1 } } */
+/* { dg-final { scan-assembler-times "mul.wide.s32" 1 } } */
+
--- /dev/null
+/* { dg-do compile } */
+/* { dg-options "-O2" } */
+
+unsigned int umulhisi3(unsigned short x, unsigned short y)
+{
+ return (unsigned int)x * (unsigned int)y;
+}
+
+unsigned long umulsidi3(unsigned int x, unsigned int y)
+{
+ return (unsigned long)x * (unsigned long)y;
+}
+
+/* { dg-final { scan-assembler-times "mul.wide.u16" 1 } } */
+/* { dg-final { scan-assembler-times "mul.wide.u32" 1 } } */
+