Path: csiph.com!3.us.feeder.erje.net!feeder.erje.net!news.linkpendium.com!news.linkpendium.com!news.snarked.org!border2.nntp.dca1.giganews.com!border1.nntp.dca1.giganews.com!nntp.giganews.com!news.iecc.com!.POSTED.news.iecc.com!nerds-end From: Kaz Kylheku <847-115-0292@kylheku.com> Newsgroups: comp.compilers Subject: Re: Optimization techniques Date: Fri, 26 Apr 2019 02:26:37 +0000 (UTC) Organization: Aioe.org NNTP Server Lines: 27 Sender: news@iecc.com Approved: comp.compilers@iecc.com Message-ID: <19-04-024@comp.compilers> References: <72d208c9-169f-155c-5e73-9ca74f78e390@gkc.org.uk> <19-04-021@comp.compilers> Injection-Info: gal.iecc.com; posting-host="news.iecc.com:2001:470:1f07:1126:0:676f:7373:6970"; logging-data="30955"; mail-complaints-to="abuse@iecc.com" Keywords: optimize, design, comment Posted-Date: 25 Apr 2019 22:34:54 EDT X-submission-address: compilers@iecc.com X-moderator-address: compilers-request@iecc.com X-FAQ-and-archives: http://compilers.iecc.com Xref: csiph.com comp.compilers:2208 On 2019-04-25, David Brown wrote: > It knows that "x * 2 / 2" is "x". It knows that "x + 1 > x" is true. Also, we could have it so that multiplication wraps, and yet in the same breath allow algebraic reductions like this anyway. Basically it can be so that, if overflow takes place in the abstract semantics of "x * 2 / 2", the result can be either the truncated version, or just x, if the algebraic reduction took place. Algebraic reductions that can change the result can be confined to evaluation regions similar to (perhaps tied to) sequence points, such that if we write: int y = x * 2; int z = y / 2; then the calculations are belabored; z is not reduced to x. Anyway, anyone who wants "x * 2 / 2" to be reduced to "x" through layers of macrology can always use a more sophisticated macro processor. Parse it, build a tree, and do the optimization in the preprocessor. C should serve as a stable "higher level assembly" target for that sort of thing. [I take your point but there's an awful lot of macros doing data structure stuff that frequently give you this kind of code. -John]