diff options
author | Jakub Jelinek <jakub@redhat.com> | 2020-03-31 11:06:43 +0200 |
---|---|---|
committer | Jakub Jelinek <jakub@redhat.com> | 2020-03-31 11:06:43 +0200 |
commit | 1dcffc8ddc48f0b45d3d0d2f763ef5870560eb9a (patch) | |
tree | b000d2ce959c64e6d7afc16c63c7c9a73d918008 /gcc/testsuite/gcc.c-torture | |
parent | 5ea39b2412269d208bb6ebd78303815957bd4f70 (diff) |
fold-const: Fix division folding with vector operands [PR94412]
The following testcase is miscompiled since 4.9, we treat unsigned
vector types as if they were signed and "optimize" negations across it.
2020-03-31 Marc Glisse <marc.glisse@inria.fr>
Jakub Jelinek <jakub@redhat.com>
PR middle-end/94412
* fold-const.c (fold_binary_loc) <case TRUNC_DIV_EXPR>: Use
ANY_INTEGRAL_TYPE_P instead of INTEGRAL_TYPE_P.
* gcc.c-torture/execute/pr94412.c: New test.
Co-authored-by: Marc Glisse <marc.glisse@inria.fr>
Diffstat (limited to 'gcc/testsuite/gcc.c-torture')
-rw-r--r-- | gcc/testsuite/gcc.c-torture/execute/pr94412.c | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/gcc/testsuite/gcc.c-torture/execute/pr94412.c b/gcc/testsuite/gcc.c-torture/execute/pr94412.c new file mode 100644 index 00000000000..6c806bbd90c --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/pr94412.c @@ -0,0 +1,28 @@ +/* PR middle-end/94412 */ + +typedef unsigned V __attribute__ ((__vector_size__ (sizeof (unsigned) * 2))); + +void +foo (V *v, V *w) +{ + *w = -*v / 11; +} + +void +bar (V *v, V *w) +{ + *w = -18 / -*v; +} + +int +main () +{ + V a = (V) { 1, 0 }; + V b = (V) { 3, __INT_MAX__ }; + V c, d; + foo (&a, &c); + bar (&b, &d); + if (c[0] != -1U / 11 || c[1] != 0 || d[0] != 0 || d[1] != -18U / -__INT_MAX__) + __builtin_abort (); + return 0; +} |