|Undefined Behavior Optimizations in C firstname.lastname@example.org (Lucian Popescu) (2023-01-05)|
|RE: Undefined Behavior Optimizations in C email@example.com (Nuno Lopes) (2023-01-05)|
|Re: Re: Undefined Behavior Optimizations in C firstname.lastname@example.org (Jon Chesterfield) (2023-01-10)|
|From:||"Nuno Lopes" <email@example.com>|
|Date:||Thu, 5 Jan 2023 10:24:13 -0000|
|Injection-Info:||gal.iecc.com; posting-host="news.iecc.com:2001:470:1f07:1126:0:676f:7373:6970"; logging-data="50911"; mail-complaints-to="firstname.lastname@example.org"|
|Posted-Date:||05 Jan 2023 11:52:36 EST|
I've a fair bit of experience with UB-related optimizations in LLVM. I don't
think the speedup and code size reduction (also important) from certain UB
exploitation is negligible. I think a better project would be to quantify
the impact of each of the UB features.
As a counter argument to your thesis, see the slides of my presentation
"Semantics for Compiler IRs: Undefined Behavior is not Evil!":
See an example here that gives a 39% speedup in a loop:
More data on how alias analysis loves UB:
There's a key implementation difficulty in doing your study. While it's
feasible to disable most UB exploitation at the clang side (not with
compiler switches, you need to change the code). At the LLVM side is
trickier to do a fair comparison. Because optimizations themselves produce
UB code, but that's fine; it's just their way of expressing invariants. But
then you cannot distinguish between what's an invariant and what's an
exploitation of UB in the program.
Don't get me wrong, I would be very keen to read such a study. But it's a
lot more work than you think to do it right.
Do ping me privately if you want more information/pointers.
From: Lucian Popescu
Sent: Thursday, January 5, 2023 10:06 AM
Subject: Undefined Behavior Optimizations in C
I'm currently working on an academic project that analyzes the speedup gain
of Undefined Behavior Optimizations in C. I argue that UB Optimizations
introduce more risks than actual speedup gains. This happens because most of
the time the compiler does not have the context to understand the intention
of the programmer in code that contains UB. ...
Return to the
Search the comp.compilers archives again.