Port-vax archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: Silly gcc bugs
On Mon, 15 Feb 2016, Martin Husemann wrote:
> > I hope this was the last issue, but please do let me know even if not.
>
> Unfortunately the new compiler fails at various places like this:
>
> # compile libgmp/hgcd2_jacobi.o
> /usr/tools/bin/vax--netbsdelf-gcc -O2 -pipe -std=gnu99 -Werror -g -Wno-stack-protector --sysroot=/hosts/vax -I. -I/usr/src/external/lgpl3/gmp/lib/libgmp/../../dist -I/usr/src/external/lgpl3/gmp/lib/libgmp/arch/vax -D__GMP_WITHIN_GMP -DHAVE_CONFIG_H -c /usr/src/external/lgpl3/gmp/lib/libgmp/../../dist/mpn/generic/hgcd2_jacobi.c -o hgcd2_jacobi.o
> (symbol_ref:SI ("__gmp_jacobi_table") [flags 0x40] <var_decl 0x7f7ff6c99980 __gmp_jacobi_table>)
> /usr/src/external/lgpl3/gmp/lib/libgmp/../../dist/mpn/generic/hgcd2_jacobi.c: In function '__gmpn_hgcd2_jacobi':
> /usr/src/external/lgpl3/gmp/lib/libgmp/../../dist/mpn/generic/hgcd2_jacobi.c:356:1: internal compiler error: output_operand: symbol used as immediate operand
> }
> ^
>
> Let me know if you need any intermediate files or whatever (this is your patch
> applied to 4.8.5 as in our current tree in the gcc.old directory)
Right, an immediate can be symbolic and on the VAX target this is a no-no
when producing PIC code. Also control shouldn't have fallen through to
this case.
Fixed thus and verified with this small test case:
extern char ptr[];
char *add(int x, int y)
{
asm("" : "+r" (x), "+r" (y));
return ptr + x + 4 * y;
}
2016-02-15 Maciej W. Rozycki <macro%linux-mips.org@localhost>
gcc/
* config/vax/vax.c (print_operand): Add the `o' operand code.
* config/vax/predicates.md (nonsymbolic_imm_operand): New
predicate.
(const_248_operand): Likewise.
* config/vax/vax.md (*addsi3_mova, *addsi4_mova): New insns.
Maciej
gcc-4.1.2-vax-mova.patch
Index: gcc-4.1.2/gcc/config/vax/predicates.md
===================================================================
--- gcc-4.1.2.orig/gcc/config/vax/predicates.md
+++ gcc-4.1.2/gcc/config/vax/predicates.md
@@ -50,6 +50,11 @@
(not (match_operand 0 "symbolic_operand")))
(match_operand 0 "general_operand" "")))
+(define_predicate "nonsymbolic_imm_operand"
+ (and (ior (match_test "!flag_pic")
+ (not (match_operand 0 "symbolic_operand")))
+ (match_operand 0 "immediate_operand" "")))
+
(define_predicate "external_memory_operand"
(match_code "mem")
{
@@ -102,3 +107,11 @@
(and (match_code "const_int,const_double,subreg,reg,mem")
(and (match_operand:DI 0 "general_operand" "")
(not (match_operand:DI 0 "illegal_addsub_di_memory_operand")))))
+
+;; Match 2, 4, or 8. Used for mova multiplicands.
+(define_predicate "const_248_operand"
+ (match_code "const_int")
+{
+ HOST_WIDE_INT i = INTVAL (op);
+ return i == 2 || i == 4 || i == 8;
+})
Index: gcc-4.1.2/gcc/config/vax/vax.c
===================================================================
--- gcc-4.1.2.orig/gcc/config/vax/vax.c
+++ gcc-4.1.2/gcc/config/vax/vax.c
@@ -425,6 +425,8 @@ print_operand (FILE *file, rtx x, int co
fputs (REGISTER_PREFIX, file);
else if (code == 'C')
fputs (rev_cond_name (x), file);
+ else if (code == 'o' && CONSTANT_P (x))
+ output_addr_const (file, x);
else if (code == 'D' && CONST_INT_P (x) && INTVAL (x) < 0)
fprintf (file, "$" NEG_HWI_PRINT_HEX16, INTVAL (x));
else if (code == 'P' && CONST_INT_P (x))
Index: gcc-4.1.2/gcc/config/vax/vax.md
===================================================================
--- gcc-4.1.2.orig/gcc/config/vax/vax.md
+++ gcc-4.1.2/gcc/config/vax/vax.md
@@ -405,6 +405,54 @@
(match_operand:DI 2 "general_operand" "Fsro,Fs")))]
"!TARGET_QMATH"
"* return vax_output_int_add (insn, operands, DImode);")
+
+;; Scaled additions using mova, needed for virtual register instantiation.
+(define_insn "*addsi3_mova"
+ [(set (match_operand:SI 0 "nonimmediate_operand" "=g")
+ (plus:SI (mult:SI (match_operand:SI 1 "register_operand" "r")
+ (match_operand 2 "const_248_operand" "n"))
+ (match_operand:SI 3 "register_operand" "r")))]
+ ""
+ "*
+{
+ int i = INTVAL (operands[2]);
+
+ switch (i)
+ {
+ case 2:
+ return \"movaw (%3)[%1],%0\";
+ case 4:
+ return \"moval (%3)[%1],%0\";
+ case 8:
+ return \"movaq (%3)[%1],%0\";
+ default:
+ gcc_unreachable ();
+ }
+}")
+
+(define_insn "*addsi4_mova"
+ [(set (match_operand:SI 0 "nonimmediate_operand" "=g")
+ (plus:SI (plus:SI (mult:SI (match_operand:SI 1 "register_operand" "r")
+ (match_operand 2 "const_248_operand" "n"))
+ (match_operand:SI 3 "register_operand" "r"))
+ (match_operand:SI 4 "nonsymbolic_imm_operand" "nT")))]
+ ""
+ "*
+{
+ int i = INTVAL (operands[2]);
+
+ switch (i)
+ {
+ case 2:
+ return \"movaw %o4(%3)[%1],%0\";
+ case 4:
+ return \"moval %o4(%3)[%1],%0\";
+ case 8:
+ return \"movaq %o4(%3)[%1],%0\";
+ default:
+ gcc_unreachable ();
+ }
+}")
;;- All kinds of subtract instructions.
Home |
Main Index |
Thread Index |
Old Index