Module Name:    src
Committed By:   rin
Date:           Sat Oct  7 12:09:06 UTC 2023

Modified Files:
        src/external/gpl3/gcc.old/dist/gcc/config/vax: builtins.md

Log Message:
gcc.old: vax: PR port-vax/57646 patch provided by Kalvis Duckmanton [16/21]

PR port-vax/50384: NetBSD/vax 7.0 gcc-4.8.4 gets ICE by SIGILL

Fix for https://gnats.netbsd.org/cgi-bin/query-pr-single.pl?number=50384
as encountered in gcc 7 in NetBSD 7.

VAX's FFS instruction as used in GCC's count_zero and ffssi2 instructions
uses the Z flag to indicate whether a set bit was found or not; GCC expects
the Z flag to consistently indicate whether the result is zero.


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 \
    src/external/gpl3/gcc.old/dist/gcc/config/vax/builtins.md

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/external/gpl3/gcc.old/dist/gcc/config/vax/builtins.md
diff -u src/external/gpl3/gcc.old/dist/gcc/config/vax/builtins.md:1.11 src/external/gpl3/gcc.old/dist/gcc/config/vax/builtins.md:1.12
--- src/external/gpl3/gcc.old/dist/gcc/config/vax/builtins.md:1.11	Mon Feb 20 02:11:22 2023
+++ src/external/gpl3/gcc.old/dist/gcc/config/vax/builtins.md	Sat Oct  7 12:09:06 2023
@@ -32,12 +32,15 @@
 
 (define_expand "ffssi2"
   [(set (match_operand:SI 0 "nonimmediate_operand" "")
-	(ffs:SI (match_operand:SI 1 "general_operand" "")))]
+	(ffs:SI (match_operand:SI 1 "general_operand" "")))
+   (set (cc0)
+	 (compare (match_dup 0) (const_int 0)))
+	 ]
   ""
   "
 {
   rtx label = gen_label_rtx ();
-  emit_insn (gen_ctzsi2 (operands[0], operands[1]));
+  emit_insn (gen_count_zero (operands[0], operands[1]));
   emit_jump_insn (gen_condjump (gen_rtx_NE(VOIDmode, cc0_rtx, const0_rtx), label));
   emit_move_insn (operands[0], constm1_rtx);
   emit_label (label);
@@ -48,7 +51,19 @@
 (define_insn "ctzsi2"
   [(set (match_operand:SI 0 "nonimmediate_operand" "=rQ")
 	(ctz:SI (match_operand:SI 1 "general_operand" "nrQT")))
-   (set (cc0) (match_dup 0))]
+    (set (cc0)
+	 (compare (match_dup 0) (const_int 0)))
+   ]
+  ""
+  "ffs $0,$32,%1,%0\;tstl %0")
+
+(define_insn "count_zero"
+  [ (set (match_operand:SI 0 "nonimmediate_operand" "")
+         (ctz:SI (match_operand:SI 1 "general_operand" "")))
+    (set (cc0)
+	 (compare (match_dup 0)
+		  (const_int 33)))
+  ]
   ""
   "ffs $0,$32,%1,%0")
 

Reply via email to