Why would you need/want string comparison instructions

Mark R

Diamond Member
Oct 9, 1999
8,513
16
81
Just seems a bit of a strange thing to add to a CPU. However as I don't do a lot of low level programming, I was wondering whether such an instruction would any value - e.g. could it be incorporated into RegExp modules or other code?

Some of the other addtions to the Core series technology include a 'bit counter' which counts the number of '1' bits in a block. I haven't the faintest idea why that would be useful.

Things like single/double precision dot products, comparisons, and multiplies I can understand. But I'm a bit baffled by the other 2.
 

CTho9305

Elite Member
Jul 26, 2000
9,214
1
81
Just seems a bit of a strange thing to add to a CPU. However as I don't do a lot of low level programming, I was wondering whether such an instruction would any value - e.g. could it be incorporated into RegExp modules or other code?

String comparison normally involves a loop, which is likely to give you at least one mispredicted branch (the final branch if the strings are equivalent). Putting it in as a microcoded instruction may allow you to perfectly predict the final not-taken branch if the strings are equivalent. If the strings aren't equivalent, the exit branch is probably going to be mispredicted.

Some of the other addtions to the Core series technology include a 'bit counter' which counts the number of '1' bits in a block. I haven't the faintest idea why that would be useful.

I forget why they're useful, but they are. AMD is introducing them in the quad core chips. I actually thought AMD would ship hardware with them first.