+2019-11-26 Jakub Jelinek <jakub@redhat.com>
+
+ PR tree-optimization/92644
+ * tree-ssa-phiopt.c (minmax_replacement): Add INTEGRAL_TYPE_P check
+ next to INTEGER_CST checks.
+
2019-11-26 Richard Biener <rguenther@suse.de>
PR tree-optimization/92645
+2019-11-26 Jakub Jelinek <jakub@redhat.com>
+
+ PR tree-optimization/92644
+ * g++.dg/opt/pr92644.C: New test.
+
2019-11-26 Richard Biener <rguenther@suse.de>
PR tree-optimization/92645
--- /dev/null
+// PR tree-optimization/92644
+// { dg-do compile { target c++14 } }
+// { dg-options "-O2 -fno-early-inlining" }
+
+inline auto foo () { return nullptr; }
+int bar () { return foo () ? 1 : 0; }
/* Turn EQ/NE of extreme values to order comparisons. */
if ((cmp == NE_EXPR || cmp == EQ_EXPR)
- && TREE_CODE (rhs) == INTEGER_CST)
+ && TREE_CODE (rhs) == INTEGER_CST
+ && INTEGRAL_TYPE_P (TREE_TYPE (rhs)))
{
if (wi::eq_p (wi::to_wide (rhs), wi::min_value (TREE_TYPE (rhs))))
{
larger = rhs;
/* If we have smaller < CST it is equivalent to smaller <= CST-1.
Likewise smaller <= CST is equivalent to smaller < CST+1. */
- if (TREE_CODE (larger) == INTEGER_CST)
+ if (TREE_CODE (larger) == INTEGER_CST
+ && INTEGRAL_TYPE_P (TREE_TYPE (larger)))
{
if (cmp == LT_EXPR)
{
larger = gimple_cond_lhs (cond);
/* If we have larger > CST it is equivalent to larger >= CST+1.
Likewise larger >= CST is equivalent to larger > CST-1. */
- if (TREE_CODE (smaller) == INTEGER_CST)
+ if (TREE_CODE (smaller) == INTEGER_CST
+ && INTEGRAL_TYPE_P (TREE_TYPE (smaller)))
{
wi::overflow_type overflow;
if (cmp == GT_EXPR)