cse.c (fold_rtx): Don't optimize if SUBREG changes mode class.

* cse.c (fold_rtx): Don't optimize if SUBREG changes mode class.

	* g++.dg/opt/cse2.C: New test.

From-SVN: r53905
This commit is contained in:
Jakub Jelinek 2002-05-26 21:59:45 +02:00 committed by Jakub Jelinek
parent 2960ccbf96
commit 9059e33cbb
4 changed files with 50 additions and 1 deletions

View File

@ -1,3 +1,7 @@
2002-05-26 Jakub Jelinek <jakub@redhat.com>
* cse.c (fold_rtx): Don't optimize if SUBREG changes mode class.
2002-05-26 Andreas Jaeger <aj@suse.de>
* cfg.c (dump_flow_info): Remove extra argument to fprintf.

View File

@ -3472,7 +3472,9 @@ fold_rtx (x, insn)
&& GET_CODE (elt->exp) != SIGN_EXTEND
&& GET_CODE (elt->exp) != ZERO_EXTEND
&& GET_CODE (XEXP (elt->exp, 0)) == SUBREG
&& GET_MODE (SUBREG_REG (XEXP (elt->exp, 0))) == mode)
&& GET_MODE (SUBREG_REG (XEXP (elt->exp, 0))) == mode
&& (GET_MODE_CLASS (mode)
== GET_MODE_CLASS (GET_MODE (XEXP (elt->exp, 0)))))
{
rtx op0 = SUBREG_REG (XEXP (elt->exp, 0));

View File

@ -1,3 +1,7 @@
2002-05-26 Jakub Jelinek <jakub@redhat.com>
* g++.dg/opt/cse2.C: New test.
2002-05-26 Neil Booth <neil@daikokuya.demon.co.uk>
* gcc.dg/cpp/arith-1.c: New semantic tests.

View File

@ -0,0 +1,39 @@
// This testcase caused ICE on IA-32 in simplify_unary_operation
// CSE did not assume SUBREGs changing mode from integral to floating.
// { dg-do run { target i?86-*-* sparc*-*-* } }
// { dg-options "-O2" }
struct A
{
union
{
float f;
unsigned int w;
} a;
static inline const A foo (void)
{
return A ((unsigned int) (__extension__ ((union { unsigned l; float d; })
{ l: 0x3f800000 }).d));
}
inline A (float f) { a.f = f; }
A ();
inline A (unsigned int w) { a.w = w; }
};
A::A()
{
*this = foo ();
}
A a;
extern "C" void abort (void);
extern "C" void exit (int);
int main ()
{
if (a.a.w != 1)
abort ();
exit (0);
}