[llvm] [RISCV] Switch to sign-extended loads if possible in RISCVOptWInstrs (PR #144703)
Alex Bradbury via llvm-commits
llvm-commits at lists.llvm.org
Thu Jun 19 07:47:43 PDT 2025
asb wrote:
> I think changing LWU->LW is useful for compression and minimizing RV32/RV64 delta.
Agreed.
> I'm skeptical that LWU->LW and LHU->LH will help us match gcc better. Here are trivial examples where LLVM used LH/LW and gcc used LHU/LWU. https://godbolt.org/z/cbje4aT7P I guess it could be better on average, but it certainly doesn't guarantee a match to gcc.
That may be true. I spotted this looking at how we had some LWU that GCC didn't in a workload and wondering if it was an indicator of us overall making some different/worse choices in terms of sign/zero extension (and of course found it was just a case where either was equivalent), and I'm sure I've seen the same before. But I totally believe there are other cases where we make different choices. I'll quantify how often it kicks in, but I probably wouldn't mind dropping LHU->LH. Perhaps the argument for this kind of change is more just "canonicalisation".
> Have you look at doing this during instruction selection using the hasAllNbitUsers in RISCVISelDAGToDAG.cpp
I'll try that and report back.
https://github.com/llvm/llvm-project/pull/144703
More information about the llvm-commits
mailing list