]> git.ipfire.org Git - thirdparty/gcc.git/commit
middle-end: Move constant args folding of .UBSAN_CHECK_* and .*_OVERFLOW into fold...
authorJakub Jelinek <jakub@redhat.com>
Thu, 15 Jun 2023 06:49:27 +0000 (08:49 +0200)
committerJakub Jelinek <jakub@redhat.com>
Thu, 15 Jun 2023 06:49:27 +0000 (08:49 +0200)
commit4e31e63ea7edffd1212fc17ce8d50672035bb64b
tree6d8b849025561968fa1b7aa91dbdd92bf196b349
parentea616f687dccbe42012f786c0ebade5b05850206
middle-end: Move constant args folding of .UBSAN_CHECK_* and .*_OVERFLOW into fold-const-call.cc

Here is an incremental patch to handle constant folding of these
in fold-const-call.cc rather than gimple-fold.cc.
Not really sure if that is the way to go because it is replacing 28
lines of former code with 65 of new code, for the overall benefit that say
int
foo (long long *p)
{
  int one = 1;
  long long max = __LONG_LONG_MAX__;
  return __builtin_add_overflow (one, max, p);
}
can be now fully folded already in ccp1 pass while before it was only
cleaned up in forwprop1 pass right after it.

On Wed, Jun 14, 2023 at 12:25:46PM +0000, Richard Biener wrote:
> I think that's still very much desirable so this followup looks OK.
> Maybe you can re-base it as prerequesite though?

Rebased then (of course with the UADDC/USUBC handling removed from this
first patch, will be added in the second one).

2023-06-15  Jakub Jelinek  <jakub@redhat.com>

* gimple-fold.cc (gimple_fold_call): Move handling of arg0
as well as arg1 INTEGER_CSTs for .UBSAN_CHECK_{ADD,SUB,MUL}
and .{ADD,SUB,MUL}_OVERFLOW calls from here...
* fold-const-call.cc (fold_const_call): ... here.
gcc/fold-const-call.cc
gcc/gimple-fold.cc