[all-commits] [llvm/llvm-project] e100d2: [DAGCombiner] Fold subtraction if above a constant...
Piotr Fusik via All-commits
all-commits at lists.llvm.org
Fri Apr 11 06:01:02 PDT 2025
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: e100d2bf9ad89139efe5b3edc441c2c67cc42bf4
https://github.com/llvm/llvm-project/commit/e100d2bf9ad89139efe5b3edc441c2c67cc42bf4
Author: Piotr Fusik <p.fusik at samsung.com>
Date: 2025-04-11 (Fri, 11 Apr 2025)
Changed paths:
M llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
M llvm/test/CodeGen/RISCV/rv32zbb.ll
M llvm/test/CodeGen/RISCV/rv64zbb.ll
Log Message:
-----------
[DAGCombiner] Fold subtraction if above a constant threshold to `umin` (#135194)
Like #134235, but with a constant.
It's a pattern in Adler-32 checksum calculation in zlib.
Example:
unsigned adler32_mod(unsigned x) {
return x >= 65521u ? x - 65521u : x;
}
Before, on RISC-V:
lui a1, 16
lui a2, 1048560
addiw a1, a1, -16
sltu a1, a1, a0
negw a1, a1
addi a2, a2, 15
and a1, a1, a2
addw a0, a0, a1
Or, with Zicond:
lui a1, 16
lui a2, 1048560
addiw a1, a1, -16
sltu a1, a1, a0
addi a2, a2, 15
czero.eqz a1, a2, a1
addw a0, a0, a1
After, with Zbb:
lui a1, 1048560
addi a1, a1, 15
addw a1, a0, a1
minu a0, a1, a0
To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications
More information about the All-commits
mailing list