Commit d578e863 by Jakub Jelinek Committed by Jakub Jelinek

re PR tree-optimization/19105 (fold does not spot anti-range test)

	PR tree-optimization/19105
	PR tree-optimization/21643
	PR tree-optimization/46309
	* tree-ssa-reassoc.c (init_range_entry): Add STMT argument
	and use it if EXP is NULL.
	(update_range_test): Handle OPCODE equal to ERROR_MARK
	and oe->op NULL.
	(optimize_range_tests): Likewise.
	(final_range_test_p, suitable_cond_bb, no_side_effect_bb, get_ops,
	maybe_optimize_range_tests): New functions.
	(reassociate_bb): Call maybe_optimize_range_tests if last
	stmt of bb is GIMPLE_COND that hasn't been visited yet.

	* gcc.dg/pr19105.c: New test.
	* gcc.dg/pr21643.c: New test.
	* gcc.dg/pr46309-2.c: New test.
	* gcc.c-torture/execute/pr46309.c: New test.

From-SVN: r193028
parent c727fb67
2012-10-31 Jakub Jelinek <jakub@redhat.com>
PR tree-optimization/19105
PR tree-optimization/21643
PR tree-optimization/46309
* tree-ssa-reassoc.c (init_range_entry): Add STMT argument
and use it if EXP is NULL.
(update_range_test): Handle OPCODE equal to ERROR_MARK
and oe->op NULL.
(optimize_range_tests): Likewise.
(final_range_test_p, suitable_cond_bb, no_side_effect_bb, get_ops,
maybe_optimize_range_tests): New functions.
(reassociate_bb): Call maybe_optimize_range_tests if last
stmt of bb is GIMPLE_COND that hasn't been visited yet.
2012-10-31 Richard Sandiford <rdsandiford@googlemail.com>
* config/rs6000/rs6000.md (insvsi, insvdi, extvsi, extvdi): Rename to...
2012-10-31 Jakub Jelinek <jakub@redhat.com>
PR tree-optimization/19105
PR tree-optimization/21643
PR tree-optimization/46309
* gcc.dg/pr19105.c: New test.
* gcc.dg/pr21643.c: New test.
* gcc.dg/pr46309-2.c: New test.
* gcc.c-torture/execute/pr46309.c: New test.
2012-10-31 Alan Modra <amodra@gmail.com>
* gcc.target/powerpc/dimode_off.c: New.
......
/* PR tree-optimization/46309 */
extern void abort (void);
unsigned int *q;
__attribute__((noinline, noclone)) void
bar (unsigned int *p)
{
if (*p != 2 && *p != 3)
(!(!(*q & 263) || *p != 1)) ? abort () : 0;
}
int
main ()
{
unsigned int x, y;
asm volatile ("" : : : "memory");
x = 2;
bar (&x);
x = 3;
bar (&x);
y = 1;
x = 0;
q = &y;
bar (&x);
y = 0;
x = 1;
bar (&x);
return 0;
}
/* PR tree-optimization/19105 */
/* { dg-do compile } */
/* { dg-options "-O2 -fdump-tree-reassoc1-details" } */
enum e
{
a, b, c, d, e, f, g, h
};
int range1 (enum e v, int x)
{
return x && v != c && v != d && v != e;
}
int range2 (enum e v, int x)
{
return x && (v != c && v != d && v != e);
}
/* { dg-final { scan-tree-dump-times "Optimizing range tests v_\[0-9\]*.D. -.2, 2. and -.3, 4.\[\n\r\]* into" 1 "reassoc1" } } */
/* { dg-final { cleanup-tree-dump "reassoc1" } } */
/* PR tree-optimization/21643 */
/* { dg-do compile } */
/* { dg-options "-O2 -fdump-tree-reassoc1-details" } */
int
f1 (unsigned char c)
{
if (c == 0x22 || c == 0x20 || c < 0x20)
return 1;
return 0;
}
int
f2 (unsigned char c)
{
if (c == 0x22 || c <= 0x20)
return 1;
return 0;
}
int
f3 (unsigned char c)
{
if (c == 0x22)
return 1;
if (c == 0x20)
return 1;
if (c < 0x20)
return 1;
return 0;
}
int
f4 (unsigned char c)
{
if (c == 0x22 || c == 0x20 || c < 0x20)
return 2;
return 0;
}
int
f5 (unsigned char c)
{
if (c == 0x22 || c <= 0x20)
return 2;
return 0;
}
int
f6 (unsigned char c)
{
if (c == 0x22)
return 2;
if (c == 0x20)
return 2;
if (c < 0x20)
return 2;
return 0;
}
int
f7 (unsigned char c)
{
if (c != 0x22 && c != 0x20 && c >= 0x20)
return 0;
return 1;
}
int
f8 (unsigned char c)
{
if (c == 0x22 && c <= 0x20)
return 0;
return 1;
}
int
f9 (unsigned char c)
{
if (c == 0x22)
return 0;
if (c == 0x20)
return 0;
if (c < 0x20)
return 0;
return 1;
}
/* { dg-final { scan-tree-dump-times "Optimizing range tests c_\[0-9\]*.D. -.0, 31. and -.32, 32.\[\n\r\]* into" 6 "reassoc1" } } */
/* { dg-final { cleanup-tree-dump "reassoc1" } } */
/* PR tree-optimization/46309 */
/* { dg-do compile } */
/* { dg-options "-O2 -fdump-tree-reassoc-details" } */
int foo (void);
void
f1 (int a)
{
_Bool v1 = (a == 3);
_Bool v2 = (a == 1);
_Bool v3 = (a == 4);
_Bool v4 = (a == 2);
if (v1 || v2 || v3 || v4)
foo ();
}
void
f2 (int a)
{
_Bool v1 = (a == 1);
_Bool v2 = (a == 2);
_Bool v3 = (a == 3);
_Bool v4 = (a == 4);
if (v1 || v2 || v3 || v4)
foo ();
}
void
f3 (unsigned int a)
{
_Bool v1 = (a <= 31);
_Bool v2 = (a >= 64 && a <= 95);
_Bool v3 = (a >= 128 && a <= 159);
_Bool v4 = (a >= 192 && a <= 223);
if (v1 || v2 || v3 || v4)
foo ();
}
void
f4 (int a)
{
_Bool v1 = (a == 3);
_Bool v2 = (a == 1);
_Bool v3 = (a == 4);
_Bool v4 = (a == 2);
_Bool v5 = (a == 7);
_Bool v6 = (a == 5);
_Bool v7 = (a == 8);
_Bool v8 = (a == 6);
if (v1 || v2 || v3 || v4 || v5 || v6 || v7 || v8)
foo ();
}
void
f5 (int a)
{
_Bool v1 = (a != 3);
_Bool v2 = (a != 1);
_Bool v3 = (a != 4);
_Bool v4 = (a != 2);
_Bool v5 = (a != 7);
_Bool v6 = (a != 5);
_Bool v7 = (a != 8);
_Bool v8 = (a != 6);
if (v1 && v2 && v3 && v4 && v5 && v6 && v7 && v8)
foo ();
}
void
f6 (int a)
{
_Bool v1 = (a != 3);
_Bool v2 = (a != 1);
_Bool v3 = (a != 4);
_Bool v4 = (a != 2);
_Bool v5 = (a != 7);
_Bool v6 = (a != 5);
_Bool v7 = (a != 8);
_Bool v8 = (a != 6);
if ((v1 && v2 && v3 && v4) && (v5 && v6 && v7 && v8))
foo ();
}
int
f7 (int a)
{
_Bool v1 = (a == 3);
_Bool v2 = (a == 1);
_Bool v3 = (a == 4);
_Bool v4 = (a == 2);
_Bool v5 = (a == 7);
_Bool v6 = (a == 5);
_Bool v7 = (a == 8);
_Bool v8 = (a == 6);
return v1 || v2 || v3 || v4 || v5 || v6 || v7 || v8;
}
_Bool
f8 (int a)
{
_Bool v1 = (a == 3);
_Bool v2 = (a == 1);
_Bool v3 = (a == 4);
_Bool v4 = (a == 2);
_Bool v5 = (a == 7);
_Bool v6 = (a == 5);
_Bool v7 = (a == 8);
_Bool v8 = (a == 6);
return v1 || v2 || v3 || v4 || v5 || v6 || v7 || v8;
}
int
f9 (int a)
{
_Bool v1 = (a != 3);
_Bool v2 = (a != 1);
_Bool v3 = (a != 4);
_Bool v4 = (a != 2);
_Bool v5 = (a != 7);
_Bool v6 = (a != 5);
_Bool v7 = (a != 8);
_Bool v8 = (a != 6);
return v1 && v2 && v3 && v4 && v5 && v6 && v7 && v8;
}
_Bool
f10 (int a)
{
_Bool v1 = (a != 3);
_Bool v2 = (a != 1);
_Bool v3 = (a != 4);
_Bool v4 = (a != 2);
_Bool v5 = (a != 7);
_Bool v6 = (a != 5);
_Bool v7 = (a != 8);
_Bool v8 = (a != 6);
return v1 && v2 && v3 && v4 && v5 && v6 && v7 && v8;
}
/* { dg-final { scan-tree-dump-times "Optimizing range tests a_\[0-9\]*.D. -.1, 1. and -.2, 2. and -.3, 3. and -.4, 4.\[\n\r\]* into" 2 "reassoc1" } } */
/* { dg-final { scan-tree-dump-times "Optimizing range tests a_\[0-9\]*.D. -.0, 31. and -.64, 95.\[\n\r\]* into" 1 "reassoc1" } } */
/* { dg-final { scan-tree-dump-times "Optimizing range tests a_\[0-9\]*.D. -.128, 159. and -.192, 223.\[\n\r\]* into" 1 "reassoc1" } } */
/* { dg-final { scan-tree-dump-times "Optimizing range tests a_\[0-9\]*.D. -.1, 1. and -.2, 2. and -.3, 3. and -.4, 4. and -.5, 5. and -.6, 6. and -.7, 7. and -.8, 8.\[\n\r\]* into" 7 "reassoc1" } } */
/* { dg-final { scan-tree-dump-times "Optimizing range tests \[^\r\n\]*_\[0-9\]* -.0, 31. and -.128, 159.\[\n\r\]* into" 1 "reassoc2" } } */
/* { dg-final { cleanup-tree-dump "reassoc1" } } */
/* { dg-final { cleanup-tree-dump "reassoc2" } } */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment