[all-commits] [llvm/llvm-project] 56ca11: [RISCV] Add an MIR pass to replace redundant sext....
Craig Topper via All-commits
all-commits at lists.llvm.org
Thu Jan 6 08:24:05 PST 2022
Author: Craig Topper <craig.topper at sifive.com>
Date: 2022-01-06 (Thu, 06 Jan 2022)
[RISCV] Add an MIR pass to replace redundant sext.w instructions with copies.
Function calls and compare instructions tend to cause sext.w
instructions to be inserted. If we make good use of W instructions,
these operations can often end up being redundant. We don't always
detect these during SelectionDAG due to things like phis. There also
some cases caused by failure to turn extload into sextload in
SelectionDAG. extload selects to LW allowing later sext.ws to become
This patch adds a pass that examines the input of sext.w instructions trying
to determine if it is already sign extended. Either by finding a
W instruction, other instructions that produce a sign extended result,
or looking through instructions that propagate sign bits. It uses
a worklist and visited set to search as far back as necessary.
Reviewed By: asb, kito-cheng
Differential Revision: https://reviews.llvm.org/D116397
More information about the All-commits