re PR tree-optimization/81346 (Missed constant propagation into comparison)
authorJakub Jelinek <jakub@redhat.com>
Wed, 19 Jul 2017 12:31:59 +0000 (14:31 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Wed, 19 Jul 2017 12:31:59 +0000 (14:31 +0200)
commit8d1628eb33d4f53832d6d4be2b0021353057a370
treed094faeffd74258f4d93793acf99507d3bb801ad
parent20deef65ae6058143c29199c1aab12d94e75181c
re PR tree-optimization/81346 (Missed constant propagation into comparison)

PR tree-optimization/81346
* fold-const.h (fold_div_compare, range_check_type): Declare.
* fold-const.c (range_check_type): New function.
(build_range_check): Use range_check_type.
(fold_div_compare): No longer static, rewritten into
a match.pd helper function.
(fold_comparison): Don't call fold_div_compare here.
* match.pd (X / C1 op C2): New optimization using fold_div_compare
as helper function.

* gcc.dg/tree-ssa/pr81346-1.c: New test.
* gcc.dg/tree-ssa/pr81346-2.c: New test.
* gcc.dg/tree-ssa/pr81346-3.c: New test.
* gcc.dg/tree-ssa/pr81346-4.c: New test.
* gcc.target/i386/umod-3.c: Hide comparison against 1 from the
compiler to avoid X / C1 op C2 optimization to trigger.

From-SVN: r250338
gcc/ChangeLog
gcc/fold-const.c
gcc/fold-const.h
gcc/match.pd
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/tree-ssa/pr81346-1.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/tree-ssa/pr81346-2.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/tree-ssa/pr81346-3.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/tree-ssa/pr81346-4.c [new file with mode: 0644]
gcc/testsuite/gcc.target/i386/umod-3.c