aboutsummaryrefslogtreecommitdiff
path: root/gcc/system.h
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2024-03-07 08:43:16 +0100
committerJakub Jelinek <jakub@redhat.com>2024-03-07 08:43:16 +0100
commit95b6ee96348041eaee9133f082b57f3e57ef0b11 (patch)
tree48ce45b9b597f606edaa0bd74508c21501f1b8b0 /gcc/system.h
parent1cd8254ebad7b73993d2acee80a7caf37c21878a (diff)
downloadgcc-95b6ee96348041eaee9133f082b57f3e57ef0b11.zip
gcc-95b6ee96348041eaee9133f082b57f3e57ef0b11.tar.gz
gcc-95b6ee96348041eaee9133f082b57f3e57ef0b11.tar.bz2
match.pd: Optimize a * !a to 0 [PR114009]
The following patch attempts to fix an optimization regression through adding a simple simplification. We already have the /* (m1 CMP m2) * d -> (m1 CMP m2) ? d : 0 */ (if (!canonicalize_math_p ()) (for cmp (tcc_comparison) (simplify (mult:c (convert (cmp@0 @1 @2)) @3) (if (INTEGRAL_TYPE_P (type) && INTEGRAL_TYPE_P (TREE_TYPE (@0))) (cond @0 @3 { build_zero_cst (type); }))) optimization which otherwise triggers during the a * !a multiplication, but that is done only late and we aren't able through range assumptions optimize it yet anyway. The patch adds a specific simplification for it. If a is zero, then a * !a will be 0 * 1 (or for signed 1-bit 0 * -1) and so 0. If a is non-zero, then a * !a will be a * 0 and so again 0. THe pattern is valid for scalar integers, complex integers and vector types, but I think will actually trigger only for the scalar integers. For vector types I've added other two with VEC_COND_EXPR in it, for complex there are different GENERIC trees to match and it is something that likely would be never matched in GIMPLE, so I didn't handle that. 2024-03-07 Jakub Jelinek <jakub@redhat.com> PR tree-optimization/114009 * genmatch.cc (decision_tree::gen): Emit ARG_UNUSED for captures argument even for GENERIC, not just for GIMPLE. * match.pd (a * !a -> 0): New simplifications. * gcc.dg/tree-ssa/pr114009.c: New test.
Diffstat (limited to 'gcc/system.h')
0 files changed, 0 insertions, 0 deletions