From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 10044 invoked by alias); 14 Oct 2008 07:19:17 -0000 Received: (qmail 9473 invoked by uid 48); 14 Oct 2008 07:17:55 -0000 Date: Tue, 14 Oct 2008 07:19:00 -0000 Message-ID: <20081014071755.9472.qmail@sourceware.org> X-Bugzilla-Reason: CC References: Subject: [Bug target/37809] [4.2/4.3/4.4 Regression] Incorrect code with MMX right shift __builtin_ia32_psradi In-Reply-To: Reply-To: gcc-bugzilla@gcc.gnu.org To: gcc-bugs@gcc.gnu.org From: "suckfish at ihug dot co dot nz" Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2008-10/txt/msg00893.txt.bz2 ------- Comment #4 from suckfish at ihug dot co dot nz 2008-10-14 07:17 ------- Digging a bit, in combine.c, the ASHIFTRT case of force_to_mode() contains two calls to simplify_shift_const(). Disabling those for vector modes fixes the test case here (patch below). But I suspect this is just the tip of the iceberg; there are probably many other arithmetic simplifications here that will get incorrectly applied to vector types, especially when sizeof(vector type) <= sizeof (HOST_WIDE_INT). Do we need to audit the whole compiler for such things, or is there a sensible place we can insert a don't-optimise-vector-types test with disabling too many useful optimisations? Thinking that the test-suite probably contains many more tests for 128 bit vector types, would it be possible/worth-while to build a compiler & run the test-suite with HOST_WIDE_INT being 128 bits? diff --git a/gcc/combine.c b/gcc/combine.c index 5821301..ad24d94 100644 --- a/gcc/combine.c +++ b/gcc/combine.c @@ -7635,7 +7635,8 @@ nonzero >>= INTVAL (XEXP (x, 1)); } - if ((mask & ~nonzero) == 0) + if ((mask & ~nonzero) == 0 + && !VECTOR_MODE_P (mode) && !VECTOR_MODE_P (GET_MODE (x))) { x = simplify_shift_const (NULL_RTX, LSHIFTRT, GET_MODE (x), XEXP (x, 0), INTVAL (XEXP (x, 1))); @@ -7643,7 +7644,8 @@ return force_to_mode (x, mode, mask, next_select); } - else if ((i = exact_log2 (mask)) >= 0) + else if ((i = exact_log2 (mask)) >= 0 + && !VECTOR_MODE_P (mode) && !VECTOR_MODE_P (GET_MODE (x))) { x = simplify_shift_const (NULL_RTX, LSHIFTRT, GET_MODE (x), XEXP (x, 0), -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37809