]> git.ipfire.org Git - thirdparty/gcc.git/commit
match.pd: simplify (view_convert (BIT_FIELD_REF))
authorArtemiy Volkov <artemiy.volkov@arm.com>
Mon, 27 Oct 2025 14:47:31 +0000 (14:47 +0000)
committerRichard Earnshaw <rearnsha@arm.com>
Tue, 28 Oct 2025 10:01:37 +0000 (10:01 +0000)
commit5eafa8d16be87339acd11446283c571b2416a532
tree190f53218f82fc22f4dbb8c7531e57633cba32db
parentb8a8bb30d950b49beeac17e3495ca78d67278cd7
match.pd: simplify (view_convert (BIT_FIELD_REF))

This patch adds a match.pd transformation to strip unnecessary
view_converts of BIT_FIELD_REFs.  This is only valid when the type of the
view_convert is a register type, and no loss of precision is involved when
casting to an integer type; both of these conditions are checked for in
the if clause of the new pattern.

The change survives bootstrap + regtest on aarch64 and x86_64, and one
additional test case has been added to gcc.dg/tree-ssa.

Changes since v1:
- Require is_gimple_reg_type (type) and remove conditions on @0
- Reword the commit message to reflect code changes

gcc/ChangeLog:

* match.pd: Add pattern to simplify view_convert (BIT_FIELD_REF).

gcc/testsuite/ChangeLog:

* gcc.dg/tree-ssa/forwprop-42.c: New test.
gcc/match.pd
gcc/testsuite/gcc.dg/tree-ssa/forwprop-42.c [new file with mode: 0644]