[PATCH] D35192: [ARM] Use ADDCARRY / SUBCARRY

Roger Ferrer Ibanez via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jul 10 02:40:56 PDT 2017


rogfer01 created this revision.
Herald added subscribers: kristof.beyls, javed.absar, aemerson.

This is a preparatory step for https://reviews.llvm.org/D34515

This patch:

- makes nodes `ISD::ADDCARRY` and `ISD::SUBCARRY` legal for `i32`
- lowering is done by first converting the boolean value into the carry flag using `(_, C) ← (ARMISD::ADDC R, -1)` and converted back to an integer value using `(R, _) ← (ARMISD::ADDE 0, 0, C)`. An `ARMISD::ADDE` between the two operations does the actual addition.
- for subtraction, given that `ISD::SUBCARRY` second result is actually a borrow, the conversion back to an integer value is done using `(R, _) ← (ARMISD::SUBE 1, 0, C)`. Here `C` is the carry value generated by the `ARMISD::SUBE` that does the actual subtraction.
- given that the generic combiner may lower `ISD::ADDCARRY` and `ISD::SUBCARRY`into `ISD::UADDO` and `ISD::USUBO` we need to update their lowering as well otherwise `i64` operations now would require branches. This implies updating the corresponding test for unsigned.
- adds new target specific combiners for sequences that conceptually do `R1 ← carryToReg(C0); C1 ← regToCarry(R1)` (just use `C0`) and their dual `C1 ← regToCarry(R0); R1 ← carryToReg(C1)` (just use `R0`).


https://reviews.llvm.org/D35192

Files:
  lib/Target/ARM/ARMISelLowering.cpp
  lib/Target/ARM/ARMISelLowering.h
  test/CodeGen/ARM/intrinsics-overflow.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D35192.105822.patch
Type: text/x-patch
Size: 10876 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170710/0d9ec39d/attachment.bin>


More information about the llvm-commits mailing list