INC/DEC vs. ADD/SUB on Intel processors

Christian Thalinger Christian.Thalinger at Sun.COM
Thu Jan 22 02:47:55 PST 2009


Hi!

Since on (newer) Intel processors it's recommended to use ADD/SUB
instead of INC/DEC (taken from Intel Optimization Reference Manual):

3.5.1.1      Use of the INC and DEC Instructions

The INC and DEC instructions modify only a subset of the bits in the flag register. This
creates a dependence on all previous writes of the flag register. This is especially
problematic when these instructions are on the critical path because they are used to
change an address for a load on which many other instructions depend.

Assembly/Compiler Coding Rule 32. (M impact, H generality) INC and DEC
instructions should be replaced with ADD or SUB instructions, because ADD and
SUB overwrite all flags, whereas INC and DEC do not, therefore creating false
dependencies on earlier instructions that set the flags.

...and HotSpot already has a UseIncDec flag, which seems not to be
changed somewhere in the code base, wouldn't it be a good idea to set
the flag to false in VM_Version::get_processor_features() for (newer)
Intel processors?

-- Christian




More information about the hotspot-compiler-dev mailing list