67 lines
2.1 KiB
Diff
67 lines
2.1 KiB
Diff
From 3293cd744508b1d6d5079294858289676680b178 Mon Sep 17 00:00:00 2001
|
|
From: Andrew Pinski <apinski@marvell.com>
|
|
Date: Tue, 9 Nov 2021 09:56:10 +0000
|
|
Subject: [PATCH 21/26] Fix tree-optimization/103152: Still one more
|
|
-signed1bit issue
|
|
|
|
When I fixed PR 102622, I accidently left behind a TYPE_PRECISION
|
|
check which I had there for checking before hand. This check
|
|
is not needed as the code will handle it correctly anyways.
|
|
|
|
Committed as obvious after a bootstrap/test on x86_64-linux-gnu.
|
|
|
|
PR tree-optimization/10352
|
|
|
|
gcc/ChangeLog:
|
|
|
|
* match.pd: Remove check of TYPE_PRECISION for
|
|
the a?0:pow2 case.
|
|
|
|
gcc/testsuite/ChangeLog:
|
|
|
|
* gcc.c-torture/execute/pr10352-1.c: New test.
|
|
|
|
Reference commit in GCC: f7844b6a777cb47fec7208d7bd594f6ce66f1daa
|
|
Signed-off-by: Pronin Alexander 00812787 <pronin.alexander@huawei.com>
|
|
---
|
|
gcc/match.pd | 3 +--
|
|
gcc/testsuite/gcc.c-torture/execute/pr10352-1.c | 12 ++++++++++++
|
|
2 files changed, 13 insertions(+), 2 deletions(-)
|
|
create mode 100644 gcc/testsuite/gcc.c-torture/execute/pr10352-1.c
|
|
|
|
diff --git a/gcc/match.pd b/gcc/match.pd
|
|
index d7d0dd0f7..9d9627fe7 100644
|
|
--- a/gcc/match.pd
|
|
+++ b/gcc/match.pd
|
|
@@ -3412,8 +3412,7 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT)
|
|
(if (integer_onep (@2))
|
|
(convert (bit_xor (convert:boolean_type_node @0) { booltrue; } )))
|
|
/* a ? powerof2cst : 0 -> (!a) << (log2(powerof2cst)) */
|
|
- (if (INTEGRAL_TYPE_P (type) && integer_pow2p (@2)
|
|
- && TYPE_PRECISION (type) != 1)
|
|
+ (if (INTEGRAL_TYPE_P (type) && integer_pow2p (@2))
|
|
(with {
|
|
tree shift = build_int_cst (integer_type_node, tree_log2 (@2));
|
|
}
|
|
diff --git a/gcc/testsuite/gcc.c-torture/execute/pr10352-1.c b/gcc/testsuite/gcc.c-torture/execute/pr10352-1.c
|
|
new file mode 100644
|
|
index 000000000..babb9d45a
|
|
--- /dev/null
|
|
+++ b/gcc/testsuite/gcc.c-torture/execute/pr10352-1.c
|
|
@@ -0,0 +1,12 @@
|
|
+/* this is another case where phiopt
|
|
+ would create -signed1bit which is undefined. */
|
|
+struct {
|
|
+ int a:1;
|
|
+} b;
|
|
+int *c = (int *)&b, d;
|
|
+int main() {
|
|
+ d = c && (b.a = (d < 0) ^ 3);
|
|
+ if (d != 1)
|
|
+ __builtin_abort();
|
|
+ return 0;
|
|
+}
|
|
--
|
|
2.27.0
|
|
|