[SelectionDAG][Mips][PowerPC][RISCV][WebAssembly] Teach computeKnownBits/ComputeNumSi...
authorJessica Clarke <jrtc27@jrtc27.com>
Wed, 5 May 2021 14:32:34 +0000 (15:32 +0100)
committerJessica Clarke <jrtc27@jrtc27.com>
Wed, 5 May 2021 15:34:45 +0000 (16:34 +0100)
commit6e876f9dedf00b24a96b8781e3b39d5282c43e91
treec25dd19ea37e06b7b19d62c1fcc2d69f00004c3c
parenta3d273c9ff4c789aec0dc743fa2dc846b5987312
[SelectionDAG][Mips][PowerPC][RISCV][WebAssembly] Teach computeKnownBits/ComputeNumSignBits about atomics

Unlike normal loads these don't have an extension field, but we know
from TargetLowering whether these are sign-extending or zero-extending,
and so can optimise away unnecessary extensions.

This was noticed on RISC-V, where sign extensions in the calling
convention would result in unnecessary explicit extension instructions,
but this also fixes some Mips inefficiencies. PowerPC sees churn in the
tests as all the zero extensions are only for promoting 32-bit to
64-bit, but these zero extensions are still not optimised away as they
should be, likely due to i32 being a legal type.

This also simplifies the WebAssembly code somewhat, which currently
works around the lack of target-independent combines with some ugly
patterns that break once they're optimised away.

Reviewed By: RKSimon, atanasyan

Differential Revision: https://reviews.llvm.org/D101342
llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
llvm/lib/Target/WebAssembly/WebAssemblyInstrAtomics.td
llvm/test/CodeGen/Mips/atomic.ll
llvm/test/CodeGen/PowerPC/atomics-i16-ldst.ll
llvm/test/CodeGen/PowerPC/atomics-i32-ldst.ll
llvm/test/CodeGen/PowerPC/atomics-i64-ldst.ll
llvm/test/CodeGen/PowerPC/atomics-i8-ldst.ll
llvm/test/CodeGen/RISCV/atomic-signext.ll