diff options
author | Andrew Pinski <quic_apinski@quicinc.com> | 2024-04-10 13:39:01 -0700 |
---|---|---|
committer | Andrew Pinski <quic_apinski@quicinc.com> | 2024-04-12 10:34:24 -0700 |
commit | 245595d72818526e2ca857848831e8afa87ae2de (patch) | |
tree | 843162598260b392bc099e624641d1dbbfce1fbd /gcc/testsuite/gcc.c-torture | |
parent | 9b8c6fffcb199b51bb9c4f46f2834f5fd0149d01 (diff) | |
download | gcc-245595d72818526e2ca857848831e8afa87ae2de.zip gcc-245595d72818526e2ca857848831e8afa87ae2de.tar.gz gcc-245595d72818526e2ca857848831e8afa87ae2de.tar.bz2 |
match: Fix `!a?b:c` and `a?~t:t` patterns for signed 1 bit types [PR114666]
The problem is `!a?b:c` pattern will create a COND_EXPR with an 1bit signed integer
which breaks patterns like `a?~t:t`. This rejects when we have a signed operand for
both patterns.
Note for GCC 15, I am going to look at the canonicalization of `a?~t:t` where t
was a constant since I think keeping it a COND_EXPR might be more canonical and
is what VPR produces from the same IR; if anything expand should handle which one
is better.
Bootstrapped and tested on x86_64-linux-gnu with no regressions.
PR tree-optimization/114666
gcc/ChangeLog:
* match.pd (`!a?b:c`): Reject signed types for the condition.
(`a?~t:t`): Likewise.
gcc/testsuite/ChangeLog:
* gcc.c-torture/execute/bitfld-signed1-1.c: New test.
Signed-off-by: Andrew Pinski <quic_apinski@quicinc.com>
Diffstat (limited to 'gcc/testsuite/gcc.c-torture')
-rw-r--r-- | gcc/testsuite/gcc.c-torture/execute/bitfld-signed1-1.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/gcc/testsuite/gcc.c-torture/execute/bitfld-signed1-1.c b/gcc/testsuite/gcc.c-torture/execute/bitfld-signed1-1.c new file mode 100644 index 0000000..b0ff120 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/bitfld-signed1-1.c @@ -0,0 +1,13 @@ +/* PR tree-optimization/114666 */ +/* We used to miscompile this to be always aborting + due to the use of the signed 1bit into the COND_EXPR. */ + +struct { + signed a : 1; +} b = {-1}; +char c; +int main() +{ + if ((b.a ^ 1UL) < 3) + __builtin_abort(); +} |