Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7443861
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T11:24:00+00:00 2026-05-29T11:24:00+00:00

The classical Multiply-Accumulate operation is a = a + b*c . But I currently

  • 0

The classical Multiply-Accumulate operation is a = a + b*c. But I currently wonder if there exist an instruction that allows to do the following operations on integer in 1 clock cycle: (a and b are unsigned 64-bit integers: unsigned long long int)

a = a*2-1
a = a*2+b

Currently, I use:

a *= 2
--a

for the first one and

a *= 2
a += b

for the second one. And I think that each one is translated to 2 instructions in ASM. But is there a way to use 1 ASM instruction instead (and with which instruction set extension on Intel CPU)?

(I search that because I do this operation billions times)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T11:24:01+00:00Added an answer on May 29, 2026 at 11:24 am
    1. For Intel CPU, see the LEA instruction. It can do both of your tasks in one instruction (not sure about cycles though) each. (eg. LEA EAX, [EAX*2+EBX]). Note that this wasn’t really meant as a multiply-add, hence its funny name (load effective address).

    2. In C and C++, you shouldn’t bother. The compiler will do what it thinks is best and you can probably just hinder its effort. I’d stay with good old a = a*2-1.

    PS: If you think something’s translated as two instructions, there is nothing easier than looking in the assembly. Then you would know.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there any built-in functionality for classical set operations on the java.util.Collection class? My
I have the classical table with expandable and collapsible records that if expanded show
I have an ecommerce website that works in a classical way: people sign up,
I wonder how many of you have implemented one of computer science's classical algorithms
I currently have an ASP Classic script that runs every 15 minutes (via scheduled
I have a project I am currently working on that has multiple validators and
I currently have a website written in classic asp that runs multiple queries against
It seems like the classical way to handle transactions with JDBC is to set
The IIS 6.0 is serving my Classical ASP pages in a serial fashion (one
Is it possible to catch a classical ASP Scripting Timeout and redirect to a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.