Skip to content
Snippets Groups Projects
Commit 903ab914 authored by Andrew Pinski's avatar Andrew Pinski
Browse files

match: Simplify `1 >> x` into `x == 0` [PR102705]


This in this PR we have missed optimization where we miss that,
`1 >> x` and `(1 >> x) ^ 1` can't be equal. There are a few ways of
optimizing this, the easiest and simpliest is to simplify `1 >> x` into
just `x == 0` as those are equivalant (if we ignore out of range values for x).
we already have an optimization for `(1 >> X) !=/== 0` so the only difference
here is we don't need the `!=/== 0` part to do the transformation.

So this removes the `(1 >> X) !=/== 0` transformation and just adds a simplfied
`1 >> x` -> `x == 0` one.

Bootstrapped and tested on x86_64-linux-gnu.

	PR tree-optimization/102705

gcc/ChangeLog:

	* match.pd (`(1 >> X) != 0`): Remove pattern.
	(`1 >> x`): New pattern.

gcc/testsuite/ChangeLog:

	* gcc.dg/tree-ssa/pr105832-2.c: Update testcase.
	* gcc.dg/tree-ssa/pr96669-1.c: Likewise.
	* gcc.dg/tree-ssa/pr102705-1.c: New test.
	* gcc.dg/tree-ssa/pr102705-2.c: New test.

Signed-off-by: default avatarAndrew Pinski <quic_apinski@quicinc.com>
parent c340ff20
No related branches found
No related tags found
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment