https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111334

--- Comment #14 from Xi Ruoyao <xry111 at gcc dot gnu.org> ---
I'm trying

diff --git a/gcc/config/loongarch/loongarch.md
b/gcc/config/loongarch/loongarch.md
index 75f641b38ee..44d9b99b2f5 100644
--- a/gcc/config/loongarch/loongarch.md
+++ b/gcc/config/loongarch/loongarch.md
@@ -64,6 +64,12 @@ (define_c_enum "unspec" [
   UNSPEC_CRC
   UNSPEC_CRCC

+  ;; 32-bit divisions can produce unspecified value if TARGET_64BIT
+  UNSPEC_DIV_W
+  UNSPEC_UDIV_W
+  UNSPEC_MOD_W
+  UNSPEC_UMOD_W
+
   UNSPEC_LOAD_FROM_GOT
   UNSPEC_PCALAU12I
   UNSPEC_ORI_L_LO12
@@ -461,6 +467,8 @@ (define_code_iterator neg_bitwise [and ior])
 ;; This code iterator allows unsigned and signed division to be generated
 ;; from the same template.
 (define_code_iterator any_div [div udiv mod umod])
+(define_code_attr ANY_DIV [(div "DIV") (udiv "UDIV")
+                          (mod "MOD") (umod "UMOD")])

 ;; This code iterator allows addition and subtraction to be generated
 ;; from the same template.
@@ -918,8 +926,9 @@ (define_insn "*<optab><mode>3"
 (define_insn "<optab>di3_fake"
   [(set (match_operand:DI 0 "register_operand" "=r,&r,&r")
        (sign_extend:DI
-         (any_div:SI (match_operand:DI 1 "register_operand" "r,r,0")
-                     (match_operand:DI 2 "register_operand" "r,r,r"))))]
+         (unspec:SI [(match_operand:DI 1 "register_operand" "r,r,0")
+                     (match_operand:DI 2 "register_operand" "r,r,r")]
+                    UNSPEC_<ANY_DIV>)))]
   ""
 {
   return loongarch_output_division ("<insn>.w<u>\t%0,%1,%2", operands);

But:

../../gcc/gcc/config/loongarch/loongarch.md:931:23: error: invalid decimal
constant "UNSPEC_<ANY_DIV>"

Reply via email to