Fix PR 100925: Limit some a?CST1:CST2 optimizations to intergal types only
authorAndrew Pinski <apinski@marvell.com>
Sun, 6 Jun 2021 04:25:58 +0000 (21:25 -0700)
committerAndrew Pinski <apinski@marvell.com>
Wed, 9 Jun 2021 19:19:43 +0000 (12:19 -0700)
commitd4faa36e7540c573c5dc17850bcd938d0900b2e9
treeaf39bfd8f989e69c6500ca2c01ee2d140994db8a
parent87e1eecaa0d96c46eab948960904fee618f926c4
Fix PR 100925: Limit some a?CST1:CST2 optimizations to intergal types only

The problem here is with offset (and pointer) types is we produce
a negative expression when this optimization hits.
It is easier to disable this optimization for all non-integeral types
instead of finding an integer type which is the same precission as the
type to do the negative expression on it.

OK? Bootstrapped and tested on x86_64-linux-gnu with no regressions.

gcc/ChangeLog:

PR tree-optimization/100925
* match.pd (a ? CST1 : CST2): Limit transformations
that would produce a negative to integeral types only.
Change !POINTER_TYPE_P to INTEGRAL_TYPE_P also.

gcc/testsuite/ChangeLog:

* g++.dg/torture/pr100925.C: New test.
gcc/match.pd
gcc/testsuite/g++.dg/torture/pr100925.C [new file with mode: 0644]