[PATCH] D70237: [X86] Add more addcarry tests

David Zarzycki via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Nov 15 02:18:37 PST 2019


davezarzycki added a comment.

Yes, please update subcarry.ll too.

And thanks, I was trying to see why the AND instruction was used by "add_U256_without_i128_or_recursive". It's not wrong but it is more complicated than it needs to be. If you are somebody else wants to add more pattern matching as a refinement, let's handle that in a subsequent patch.

My patch is designed to recognize the following pattern (which clang happens to generate but I didn't know that going in):

  temp[n] = x[n] + y[n];
  result[n] = temp[n] + ((temp[n-1] < x[n-1]) | (result[n-1] < temp[n-1]));

In English: "either the previous addition overflowed or the previous carry propagation overflowed (but they cannot both overflow)."

Because the two carries cannot both overflow at the same time, you can also use XOR or ADD to merge the carry flags, but ADD is more difficult to pattern match because the compiler can commute the additions.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D70237/new/

https://reviews.llvm.org/D70237





More information about the llvm-commits mailing list