]> git.ipfire.org Git - thirdparty/gcc.git/commit
PR tree-optimization/71343: Value number X<<2 as X*4.
authorRoger Sayle <roger@nextmovesoftware.com>
Wed, 11 Jan 2023 16:54:58 +0000 (16:54 +0000)
committerRoger Sayle <roger@nextmovesoftware.com>
Wed, 11 Jan 2023 16:54:58 +0000 (16:54 +0000)
commit98837d6e79dd27c15f5218f3f1ddf838cda4796c
treefde16497c0e452d16b312eee25175a6a745a0882
parentc7279270a2deda81eaeba37a87d721bee0ed6004
PR tree-optimization/71343: Value number X<<2 as X*4.

This patch is the second part of a fix for PR tree-optimization/71343,
that implements Richard Biener's suggestion of using tree-ssa's value
numbering instead of match.pd.  The change is that when assigning a
value number for the expression X<<C, we actually look-up or insert
the value number for the multiplication X*(1<<C).  This elegantly
handles the fact that we (intentionally) don't canonicalize these as
equivalent in GIMPLE, and the optimization/equivalence in PR 71343 now
happens by (tree-ssa SCCVN) magic.

2023-01-11  Roger Sayle  <roger@nextmovesoftware.com>

gcc/ChangeLog
PR tree-optimization/71343
* tree-ssa-sccvn.cc (visit_nary_op) <case LSHIFT_EXPR>: Make
the value number of the expression X << C the same as the value
number for the multiplication X * (1<<C).

gcc/testsuite/ChangeLog
PR tree-optimization/71343
* gcc.dg/pr71343-2.c: New test case.
gcc/testsuite/gcc.dg/pr71343-2.c [new file with mode: 0644]
gcc/tree-ssa-sccvn.cc