From ab034cfc0ae8017daee188d4e1ea971d77c30a1a Mon Sep 17 00:00:00 2001 From: Richard Kenner Date: Tue, 27 Apr 1993 07:38:37 -0400 Subject: [PATCH] (alpha_emit_set_const... (alpha_emit_set_const, output_{pro,epi}log): Generate insns to load constants into a register using a method that works on a 32-bit machine as well. From-SVN: r4246 --- gcc/config/alpha/alpha.c | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/gcc/config/alpha/alpha.c b/gcc/config/alpha/alpha.c index 6ecb98e..13c5e54 100644 --- a/gcc/config/alpha/alpha.c +++ b/gcc/config/alpha/alpha.c @@ -1,5 +1,5 @@ /* Subroutines used for code generation on the DEC Alpha. - Copyright (C) 1992 Free Software Foundation, Inc. + Copyright (C) 1992, 1993 Free Software Foundation, Inc. Contributed by Richard Kenner (kenner@nyu.edu) This file is part of GNU CC. @@ -600,10 +600,12 @@ alpha_emit_set_const (target, c, n) HOST_WIDE_INT tmp1 = c - low; HOST_WIDE_INT high = ((tmp1 >> 16) & 0xffff) - 2 * ((tmp1 >> 16) & 0x8000); - HOST_WIDE_INT tmp2 = c - (high << 16) - low; HOST_WIDE_INT extra = 0; - if (tmp2) + /* If HIGH will be interpreted as negative but the constant is + positive, we must adjust it to do two ldha insns. */ + + if ((high & 0x8000) != 0 && c >= 0) { extra = 0x4000; tmp1 -= 0x40000000; @@ -1190,11 +1192,14 @@ output_prolog (file, size) HOST_WIDE_INT tmp1 = blocks - low; HOST_WIDE_INT high = ((tmp1 >> 16) & 0xffff) - 2 * ((tmp1 >> 16) & 0x8000); - HOST_WIDE_INT tmp2 = blocks - (high << 16) - low; HOST_WIDE_INT extra = 0; int in_reg = 31; - if (tmp2) + /* If HIGH will be interpreted as negative, we must adjust it to + do two ldha insns. Note that we will never be building a negative + constant here. */ + + if (high & 0x8000) { extra = 0x4000; tmp1 -= 0x40000000; @@ -1351,7 +1356,6 @@ output_epilog (file, size) HOST_WIDE_INT tmp1 = frame_size - low; HOST_WIDE_INT high = ((tmp1 >> 16) & 0xffff) - 2 * ((tmp1 >> 16) & 0x8000); - HOST_WIDE_INT tmp2 = frame_size - (high << 16) - low; HOST_WIDE_INT extra = 0; int in_reg = 31; @@ -1361,7 +1365,11 @@ output_epilog (file, size) abort (); #endif - if (tmp2) + /* If HIGH will be interpreted as negative, we must adjust it to + do two ldha insns. Note that we will never be building a negative + constant here. */ + + if (high & 0x8000) { extra = 0x4000; tmp1 -= 0x40000000; -- 2.7.4