]> git.ipfire.org Git - thirdparty/gcc.git/commit
[committed] [v2] More logical op simplifications in simplify-rtx.cc
authorJeff Law <jlaw@ventanamicro.com>
Sat, 25 May 2024 18:39:05 +0000 (12:39 -0600)
committerJeff Law <jlaw@ventanamicro.com>
Sat, 25 May 2024 18:41:26 +0000 (12:41 -0600)
commit05daf617ea22e1d818295ed2d037456937e23530
treed8bc754c266983912e1975a24b3eb0c55d401ca9
parent28b508233a12c13295f960a2cb8a4864879acfb4
[committed] [v2] More logical op simplifications in simplify-rtx.cc

This is a revamp of what started as a target specific patch.

Basically xalan (corrected, I originally thought it was perlbench) has a bitset
implementation with a bit of an oddity.  Specifically setBit will clear the bit
before it is set:

>             if (bitToSet < 32)
>             {
>                 fBits1 &= ~mask;
>                 fBits1 |= mask;
>             }
>              else
>             {
>                 fBits2 &= ~mask;
>                 fBits2 |= mask;
>             }
We can clean this up pretty easily in RTL with a small bit of code in
simplify-rtx.  While xalan doesn't have other cases, we can synthesize tests
pretty easily and handle them as well.

It turns out we don't actually have to recognize this stuff at the bit level,
just standard logical identities are sufficient.  For example

(X | Y) & ~Y -> X & ~Y

Andrew P. might poke at this at the gimple level.  The type changes kindof get
in the way in gimple but he's much better at match.pd than I am, so if he wants
to chase it from the gimple side, I'll fully support that.

Bootstrapped and regression tested on x86.  Also run through my tester on its
embedded targets.

Pushing to the trunk.

gcc/

* simplify-rtx.cc (simplify_context::simplify_binary_operation_1): Handle
more logical simplifications.

gcc/testsuite/

* g++.target/riscv/redundant-bitmap-1.C: New test.
* g++.target/riscv/redundant-bitmap-2.C: New test.
* g++.target/riscv/redundant-bitmap-3.C: New test.
* g++.target/riscv/redundant-bitmap-4.C: New test.
gcc/simplify-rtx.cc
gcc/testsuite/g++.target/riscv/redundant-bitmap-1.C [new file with mode: 0644]
gcc/testsuite/g++.target/riscv/redundant-bitmap-2.C [new file with mode: 0644]
gcc/testsuite/g++.target/riscv/redundant-bitmap-3.C [new file with mode: 0644]
gcc/testsuite/g++.target/riscv/redundant-bitmap-4.C [new file with mode: 0644]