diff options
author | Luke Lau <luke@igalia.com> | 2024-03-25 13:08:56 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-03-25 13:08:56 +0800 |
commit | 373e77b4c0ad9b0bf370f0e5a32a4100a5459d82 (patch) | |
tree | fa54688035fa9df49f46340bdfe63cb341617bcf /clang/unittests/Interpreter/InterpreterTest.cpp | |
parent | d9746a6a5d523e21eee2c1b50c2f08aa19396965 (diff) | |
download | llvm-373e77b4c0ad9b0bf370f0e5a32a4100a5459d82.zip llvm-373e77b4c0ad9b0bf370f0e5a32a4100a5459d82.tar.gz llvm-373e77b4c0ad9b0bf370f0e5a32a4100a5459d82.tar.bz2 |
[RISCV] Generalize (sub zext, zext) -> (sext (sub zext, zext)) to add (#86248)
This generalizes the combine added in #82455 to other binary ops,
beginning with adds in this patch.
Because the two zext operands are always +ve when treated as signed, and
we don't get any overflow since the add is carried out in at least N * 2
bits of the narrow type, the result of the add will always be +ve. So we
can use a zext for the outer extend, unlike sub which may produce a -ve
result from two +ve operands.
Although we could still use sext for add, I plan to add support for
other binary ops like mul in a later patch, but mul requires zext to be
correct (because the maximum value will take up the full N * 2 bits). So
I've opted to use zext here too for consistency.
Alive2 proof: https://alive2.llvm.org/ce/z/PRNsUM
Diffstat (limited to 'clang/unittests/Interpreter/InterpreterTest.cpp')
0 files changed, 0 insertions, 0 deletions