aboutsummaryrefslogtreecommitdiff
path: root/gcc/fold-const.cc
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2022-01-29 17:54:43 +0100
committerJakub Jelinek <jakub@redhat.com>2022-01-29 17:54:43 +0100
commita1544878966020d1f7a640b35d1f7a5f0e055624 (patch)
tree6578967d246f4f0b2147cb07cc2915b4772b552a /gcc/fold-const.cc
parentf6f2d6cfec1c2fe9570b98211be58329d8d7749b (diff)
downloadgcc-a1544878966020d1f7a640b35d1f7a5f0e055624.zip
gcc-a1544878966020d1f7a640b35d1f7a5f0e055624.tar.gz
gcc-a1544878966020d1f7a640b35d1f7a5f0e055624.tar.bz2
match.pd: Fix up 1 / X for unsigned X optimization [PR104280]
On Fri, Jan 28, 2022 at 11:38:23AM -0700, Jeff Law wrote: > Thanks.  Given the original submission and most of the review work was done > prior to stage3 closing, I went ahead and installed this on the trunk. Unfortunately this breaks quite a lot of things. The main problem is that GIMPLE allows EQ_EXPR etc. only with BOOLEAN_TYPE or with TYPE_PRECISION == 1 integral type (or vector boolean). Violating this causes verification failures in tree-cfg.cc in some cases, in other cases wrong-code issues because before it is verified we e.g. transform 1U / x into x == 1U and later into x (because we assume that == type must be one of the above cases and when it is the same type as the type of the first operand, for boolean-ish cases it should be equivalent). Fixed by changing that (eq @1 { build_one_cst (type); }) into (convert (eq:boolean_type_node @1 { build_one_cst (type); })) Note, I'm not 100% sure if :boolean_type_node is required in that case, I see some spots in match.pd that look exactly like this, while there is e.g. (convert (le ...)) that supposedly does the right thing too. The signed integer 1/X case doesn't need changes changes, for (cond (le ...) ...) le gets correctly boolean_type_node and cond should use type. I've also reformatted it, some lines were too long, match.pd uses indentation by 1 column instead of 2 etc. 2022-01-29 Jakub Jelinek <jakub@redhat.com> Andrew Pinski <apinski@marvell.com> PR tree-optimization/104279 PR tree-optimization/104280 PR tree-optimization/104281 * match.pd (1 / X -> X == 1 for unsigned X): Build eq with boolean_type_node and convert to type. Formatting fixes. * gcc.dg/torture/pr104279.c: New test. * gcc.dg/torture/pr104280.c: New test. * gcc.dg/torture/pr104281.c: New test.
Diffstat (limited to 'gcc/fold-const.cc')
0 files changed, 0 insertions, 0 deletions