please note: going title question "when use registers in c?", seems already beat me punch. however, way question asked when compared title bit misleading, , believe question unique , not dupe of it.
whereas, question ought have been titled "are register variables faster?", want know when 1 should using registers. it's obvious me in fact faster, cpu has many register on chip, , limited can store on them.
so ask: how select variables should qualified register? variables used frequency? variables of particular size or type? variables used in compute-bound problems? else?
i @ this: every product owner or stakeholder, every single bug or feature "top priority" , critical. if analyse needs, see features in deed more "top priority" others. code, want run fast possible, , i'm sure every variable candidate optimization/performance tuning. imagine if analyse program (or c compiler matter, let's assume gcc), i'm sure there's way determine variables best suited use register.
first, let me tell you, don't fooled presence of register in c source code.
your compiler absolutely free ignore (and of time, does). in modern compiler, using register useless.
usually, "standard" compiler have own algorithm detect , put appropriate variables allocate them registers (or not). of time, surprisingly correct. leave them.
fwiw, 1 thing remember, cannot address of register variable. reason (if can consider "reason") use register. maybe.
Comments
Post a Comment