[PATCH] D78439: [AVR] Fix miscompilation of zext + add
Ayke via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Jun 18 08:08:17 PDT 2020
aykevl added a comment.
Patch committed!
I looked for other instances of this bug, see below.
def : Pat<(add i16:$src1, imm0_63_neg:$src2),
(SBIWRdK i16:$src1, (imm0_63_neg:$src2))>;
def : Pat<(add i16:$src1, imm:$src2),
(SUBIWRdK i16:$src1, (imm16_neg_XFORM imm:$src2))>;
Both don't involve a carry bit, so should be fine.
def : Pat<(addc i16:$src1, imm:$src2),
(SUBIWRdK i16:$src1, (imm16_neg_XFORM imm:$src2))>;
`addc` means "add with carry" while `subiw` is expanded to `subi`/`sbci` which discards the incoming carry bit. This may be a bug.
def : Pat<(add i8:$src1, imm:$src2),
(SUBIRdK i8:$src1, (imm8_neg_XFORM imm:$src2))>;
No carry bits, so should be fine.
def : Pat<(addc i8:$src1, imm:$src2),
(SUBIRdK i8:$src1, (imm8_neg_XFORM imm:$src2))>;
Like `addc i16`, this discards the carry bit so may be a bug.
def : Pat<(adde i8:$src1, imm:$src2),
(SBCIRdK i8:$src1, (imm8_neg_XFORM imm:$src2))>;
`adde` means an add with a carry input and carry output. The `sbci` instruction does the same thing, except that it uses the carry in the wrong direction (subtracting instead of adding). Basically the 8-bit version of the bug this patch is about.
I don't have any code to check, but will leave this here for future reference.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D78439/new/
https://reviews.llvm.org/D78439
More information about the llvm-commits
mailing list