https://gcc.gnu.org/bugzilla/show_bug.cgi?id=120948

--- Comment #5 from Richard Biener <rguenth at gcc dot gnu.org> ---
A better representation than if (...) __builtin_unrechable (); for asserts
would be nice.  We have with __builtin_assume_aligned something very related.
So in GIMPLE we could have

_2 = .ASSUME (_1, !=, 0);

with != encoded as integer tree code.  But of course if we'd want to expose
this to the user it might instead be

x = __builtin_assume (x != 0);

with the syntactic requirement that the argument is a compare and the
left operator is a ID (IIRC OpenMP pragmas often have similar constraints).

Of course there's no need to expose this to users in the first place.

Having

_3 = _1 != 0;
_2 = .ASSUME (_1, _3);

is more difficult because the separate predicate stmt will confuse size/time
metrics.

So _2 = 1 / x_1 would be turned into

x_3 = .ASSUME (x_1, !=, 0);
_2 = x_3 == 1;

note that nothing prevents code motion of the above and the conditional would
still be

if (x_1 == 0)
  return 5;

which means unless we rewrite all uses of x_1 to x_3 it might not achieve
what we intend to.

Reply via email to