aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Transforms/Utils/SimplifyIndVar.cpp
diff options
context:
space:
mode:
authorMin-Yih Hsu <min.hsu@sifive.com>2023-11-03 09:03:52 -0700
committerGitHub <noreply@github.com>2023-11-03 09:03:52 -0700
commit1e39575a981088e8596461a3511cce3ec4c3b274 (patch)
tree31fcbc3b6c1f8f77fe66e5e30e929affd5daea95 /llvm/lib/Transforms/Utils/SimplifyIndVar.cpp
parent015c06ade023362ba7410e06618dea407fa07e5f (diff)
downloadllvm-1e39575a981088e8596461a3511cce3ec4c3b274.zip
llvm-1e39575a981088e8596461a3511cce3ec4c3b274.tar.gz
llvm-1e39575a981088e8596461a3511cce3ec4c3b274.tar.bz2
[RISCV] CSE by swapping conditional branches (#71111)
DAGCombiner, as well as InstCombine, tend to canonicalize GE/LE into GT/LT, namely: ``` X >= C --> X > (C - 1) ``` Which sometime generates off-by-one constants that could have been CSE'd with surrounding constants. Instead of changing such canonicalization, this patch tries to swap those branch conditions post-isel, in the hope of resurfacing more constant CSE opportunities. More specifically, it performs the following optimization: For two constants C0 and C1 from ``` li Y, C0 li Z, C1 ``` To remove redundnat `li Y, C0`, 1. if C1 = C0 + 1 we can turn: (a) blt Y, X -> bge X, Z (b) bge Y, X -> blt X, Z 2. if C1 = C0 - 1 we can turn: (a) blt X, Y -> bge Z, X (b) bge X, Y -> blt Z, X This optimization will be done by PeepholeOptimizer through RISCVInstrInfo::optimizeCondBranch.
Diffstat (limited to 'llvm/lib/Transforms/Utils/SimplifyIndVar.cpp')
0 files changed, 0 insertions, 0 deletions