View Issue Details

IDProjectCategoryView StatusLast Update
0030411RunnerVariables (In-Built)Public2019-05-13 16:28
ReporterYellowAfterlifeAssigned ToRussell Kay 
PriorityLowSeverityC - GeneralReproducibility100%
Status ClosedResolutionFixed 
PlatformOSWindows 10 ProOS Version>=1703
Product Version2.2.1 
Target Version2.2.3Fixed in Version2.2.3 
Summary0030411: Variables: i++; is observably slower than ++i; on YYC
DescriptionPostfix operator (YYRValue operator++(int)) returns a by-value copy of YYRValue, which makes sense.
However, postfix operators are utilized even when the expression is used as a statement, and C++ compiler will not swap them out for prefix ones, therefore writing out your for-loop as
for (var i = a; i < b; i++) { ... }

instead of
for (var i = a; i < b; ++i) { ... }

will have your program waste time every iteration on allocation/cleanup of YYRValues for postfix operator, all for virtually no gain.

Therefore it would make sense to detect that a postfix operator is being used as a statement and print it as a prefix operator instead.
Additional InformationI have to admit that I've seen people use consistently use ++i; before but have not given this much attention until noticing that approx 1/6th of time in my serializer goes literally just to postfix operators.
TagsCompiler, yyc
1.4 Found In
2.x Runtime Found In9.9.1.1298
2.x Runtime Verified In9.9.1.1437

Activities

YellowAfterlife

2019-01-10 13:35

Developer  

a_bug.yyz (19,026 bytes)

Russell Kay

2019-01-10 13:43

Manager   ~0062435

Not technically a bug... but it would be a nice optimisation across the board (would also help in VM) - I wonder if I could do the optimisation in the compiler frontend so everything would get the same optimisation

Russell Kay

2019-01-22 11:01

Manager   ~0062477

Fixed in gitlab