Skip to content
Snippets Groups Projects
Commit 65061ea2 authored by Jakub Jelinek's avatar Jakub Jelinek
Browse files

phiopt: Optimize partial_ordering spaceship >= 0 -ffinite-math-only [PR94589]

As mentioned earlier, spaceship_replacement didn't optimize partial_ordering
>= 0 comparisons, because the possible values are -1, 0, 1, 2 and the
>= comparison is implemented as (res & 1) == res to choose the 0 and 1
cases from that.  As we optimize that only with -ffinite-math-only, the
2 case is assumed not to happen and my earlier match.pd change optimizes
(res & 1) == res into (res & ~1) == 0, so this patch pattern matches
that case and handles it like res >= 0.

2021-05-18  Jakub Jelinek  <jakub@redhat.com>

	PR tree-optimization/94589
	* tree-ssa-phiopt.c (spaceship_replacement): Pattern match
	phi result used in (res & ~1) == 0 comparison as res >= 0 as
	res == 2 would be UB with -ffinite-math-only.

	* g++.dg/opt/pr94589-2.C: Adjust scan-tree-dump count from 14 to 12.
parent b2a09773
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