Index: llvm/lib/Target/RISCV/CMakeLists.txt =================================================================== --- llvm/lib/Target/RISCV/CMakeLists.txt +++ llvm/lib/Target/RISCV/CMakeLists.txt @@ -21,6 +21,7 @@ add_llvm_target(RISCVCodeGen RISCVAsmPrinter.cpp RISCVCallLowering.cpp + RISCVCompressInstrs.cpp RISCVExpandAtomicPseudoInsts.cpp RISCVExpandPseudoInsts.cpp RISCVFrameLowering.cpp Index: llvm/lib/Target/RISCV/RISCV.h =================================================================== --- llvm/lib/Target/RISCV/RISCV.h +++ llvm/lib/Target/RISCV/RISCV.h @@ -37,6 +37,9 @@ FunctionPass *createRISCVISelDag(RISCVTargetMachine &TM); +FunctionPass *createRISCVCompressInstrsOptPass(); +void initializeRISCVCompressInstrsOptPass(PassRegistry &); + FunctionPass *createRISCVGatherScatterLoweringPass(); void initializeRISCVGatherScatterLoweringPass(PassRegistry &); Index: llvm/lib/Target/RISCV/RISCVCompressInstrs.cpp =================================================================== --- /dev/null +++ llvm/lib/Target/RISCV/RISCVCompressInstrs.cpp @@ -0,0 +1,365 @@ +//===-- RISCVCompressInstrs.cpp - Make instructions compressible ----------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// +// +// This pass searches for instructions that are prevented from being compressed +// by one of the following: +// +// 1. The use of a single uncompressed register. +// 2. A base register + offset where the offset is too large to be compressed +// and the base register may or may not be compressed. +// +// +// For case 1, if a compressed register is available, then the uncompressed +// register is copied to the compressed register and its uses are replaced. +// +// For example, storing zero uses the uncompressible zero register: +// sw zero, 0(a0) # if zero +// sw zero, 8(a0) # if zero +// sw zero, 4(a0) # if zero +// sw zero, 24(a0) # if zero +// +// If a compressed register (e.g. a1) is available, the above can be transformed +// to the following to improve code size: +// li a1, 0 +// c.sw a1, 0(a0) +// c.sw a1, 8(a0) +// c.sw a1, 4(a0) +// c.sw a1, 24(a0) +// +// +// For case 2, if a compressed register is available, then the original base +// is copied and adjusted such that: +// +// new_base_register = base_register + adjustment +// base_register + large_offset = new_base_register + small_offset +// +// For example, the following offsets are too large for c.sw: +// lui a2, 983065 +// sw a1, -236(a2) +// sw a1, -240(a2) +// sw a1, -244(a2) +// sw a1, -248(a2) +// sw a1, -252(a2) +// sw a0, -256(a2) +// +// If a compressed register is available (e.g. a3), a new base could be created +// such that the addresses can accessed with a compressible offset, thus +// improving code size: +// lui a2, 983065 +// addi a3, a2, -256 +// c.sw a1, 20(a3) +// c.sw a1, 16(a3) +// c.sw a1, 12(a3) +// c.sw a1, 8(a3) +// c.sw a1, 4(a3) +// c.sw a0, 0(a3) +// +// +// This optimization is only applied if there are enough uses of the copied +// register for code size to be reduced. +// +//===----------------------------------------------------------------------===// + +#include "RISCV.h" +#include "RISCVSubtarget.h" +#include "llvm/CodeGen/Passes.h" +#include "llvm/CodeGen/RegisterScavenging.h" +#include "llvm/Support/Debug.h" +#include "llvm/Support/TargetRegistry.h" + +using namespace llvm; + +#define DEBUG_TYPE "riscv-compress-instrs" +#define RISCV_COMPRESS_INSTRS_NAME "RISCV Compress Instructions" + +namespace { + +struct RISCVCompressInstrsOpt : public MachineFunctionPass { + static char ID; + + bool runOnMachineFunction(MachineFunction &Fn) override; + + RISCVCompressInstrsOpt() : MachineFunctionPass(ID) { + initializeRISCVCompressInstrsOptPass(*PassRegistry::getPassRegistry()); + } + + StringRef getPassName() const override { return RISCV_COMPRESS_INSTRS_NAME; } +}; +} // namespace + +char RISCVCompressInstrsOpt::ID = 0; +INITIALIZE_PASS(RISCVCompressInstrsOpt, "riscv-compress-instrs", + RISCV_COMPRESS_INSTRS_NAME, false, false) + +// Return log2(widthInBytes) of load/store done by Opcode. +static uint8_t log2LdstWidth(unsigned Opcode) { + switch (Opcode) { + default: + llvm_unreachable("Unexpected opcode"); + case RISCV::LW: + case RISCV::SW: + case RISCV::FLW: + case RISCV::FSW: + return 2; + case RISCV::LD: + case RISCV::SD: + case RISCV::FLD: + case RISCV::FSD: + return 3; + } +} + +// Return a mask for the offset bits of a non-stack-pointer based compressed +// load/store. +static uint8_t compressedLDSTOffsetMask(unsigned Opcode) { + return 0x1f << log2LdstWidth(Opcode); +} + +// Return true if Offset fits within a compressed stack-pointer based +// load/store. +static bool compressibleSPOffset(int64_t Offset, unsigned Opcode) { + return isShiftedUIntN(6, log2LdstWidth(Opcode), Offset); +} + +// Return true if Offset fits within a non-stack-pointer based compressed +// load/store. +static bool compressibleOffset(int64_t Offset, unsigned Opcode) { + return isShiftedUIntN(5, log2LdstWidth(Opcode), Offset); +} + +// Given an offset for a load/store, return the adjustment required to the base +// register such that the address can be accessed with a compressible offset. +// Return 0 if the offset is already compressible. +static int64_t getBaseAdjustForCompression(int64_t Offset, unsigned Opcode) { + if (compressibleOffset(Offset, Opcode)) + return 0; + // Return the excess bits that do not fit in a compressible offset. + return Offset & ~compressedLDSTOffsetMask(Opcode); +} + +// Return true if Reg is in a compressed register class. +static bool compressedReg(Register Reg) { + return RISCV::GPRCRegClass.contains(Reg) || + RISCV::FPR32CRegClass.contains(Reg) || + RISCV::FPR64CRegClass.contains(Reg); +} + +// Return true if Opcode is a load for which there exists a compressed version. +static bool compressibleLoad(const unsigned Opcode) { + return Opcode == RISCV::LW || Opcode == RISCV::FLW || Opcode == RISCV::LD || + Opcode == RISCV::FLD; +} + +// Return true if Opcode is a store for which there exists a compressed version. +static bool compressibleStore(const unsigned Opcode) { + return Opcode == RISCV::SW || Opcode == RISCV::FSW || Opcode == RISCV::SD || + Opcode == RISCV::FSD; +} + +// Find a single register and/or large offset which, if compressible, would +// allow the given instruction to be compressed. +// +// Possible return values: +// {Reg, 0} - Uncompressed Reg needs replacing with a compressed register. +// {Reg, N} - Reg needs replacing with a compressed register and N needs +// adding to the new register. (Reg may be compressed or +// uncompressed). +// {RISCV::NoRegister, 0} - No suitable optimization found for this +// instruction. +static RegImmPair getRegImmPairPreventingCompression(const MachineInstr &MI) { + const unsigned Opcode = MI.getOpcode(); + + if (compressibleLoad(Opcode) || compressibleStore(Opcode)) { + const MachineOperand &MOImm = MI.getOperand(2); + if (!MOImm.isImm()) + return RegImmPair(RISCV::NoRegister, 0); + ; + + int64_t Offset = MOImm.getImm(); + int64_t NewBaseAdjust = getBaseAdjustForCompression(Offset, Opcode); + Register Base = MI.getOperand(1).getReg(); + + // Memory accesses via the stack pointer do not have a requirement for + // either of the registers to be compressible and the offset can be a 6 bit + // immediate scaled by 4. + if (RISCV::SPRegClass.contains(Base)) { + if (!compressibleSPOffset(Offset, Opcode) && NewBaseAdjust) + return RegImmPair(Base, NewBaseAdjust); + } else { + Register Rs2 = MI.getOperand(0).getReg(); + bool Rs2Compressed = compressedReg(Rs2); + bool BaseCompressed = compressedReg(Base); + + if ((!BaseCompressed || NewBaseAdjust) && Rs2Compressed) + return RegImmPair(Base, NewBaseAdjust); + + // For loads we can only change the base register since dest is defined + // rather than used. + if (compressibleStore(Opcode)) { + // Cannot resolve uncompressible offset if we are resolving src reg. + if (!Rs2Compressed && (BaseCompressed || Rs2 == Base) && !NewBaseAdjust) + return RegImmPair(Rs2, NewBaseAdjust); + } + } + } + return RegImmPair(RISCV::NoRegister, 0); +} + +// Check all uses after FirstMI of the given register, keeping a vector of +// instructions that would be compressible if the given register (and offset if +// applicable) were compressible. +// +// If there are enough uses for this optimization to improve code size and a +// compressed register is available, return that compressed register. +static Register analyzeCompressibleUses(MachineBasicBlock &MBB, + MachineInstr &FirstMI, + RegImmPair RegImm, + SmallVectorImpl &MIs) { + const TargetRegisterInfo *TRI = + MBB.getParent()->getSubtarget().getRegisterInfo(); + + RegScavenger RS; + RS.enterBasicBlock(MBB); + + for (MachineBasicBlock::instr_iterator I = FirstMI.getIterator(), + E = MBB.instr_end(); + I != E; ++I) { + MachineInstr &MI = *I; + + // Determine if this is an instruction which would benefit from using the + // new register. + RegImmPair CandidateRegImm = getRegImmPairPreventingCompression(MI); + if (CandidateRegImm.Reg == RegImm.Reg && + CandidateRegImm.Imm == RegImm.Imm) { + // Advance tracking since the value in the new register must be live for + // this instruction too. + RS.forward(I); + + MIs.push_back(&MI); + } + + // If RegImm.Reg is modified by this instruction then we cannot optimize + // past this instruction. If the register is already compressed then it may + // possible to optimize a large offset in the current instruction - this + // will have been detected by the preceeding call to + // getRegImmPairPreventingCompression. + if (MI.modifiesRegister(RegImm.Reg, TRI)) + break; + } + + // Adjusting the base costs one new uncompressed addi and therefore three uses + // are required for a code size reduction. If no base adjustment is required, + // then copying the register costs one new c.mv (or c.li Rd, 0 for "copying" + // the zero register) and therefore two uses are required for a code size + // reduction. + if (MIs.size() < 2 || (RegImm.Imm != 0 && MIs.size() < 3)) + return RISCV::NoRegister; + + // Find a compressible register which will be available from the first + // instruction we care about to the last. + const TargetRegisterClass *RCToScavenge; + + // Work out the compressed register class from which to scavenge. + if (RISCV::GPRRegClass.contains(RegImm.Reg)) + RCToScavenge = &RISCV::GPRCRegClass; + else if (RISCV::FPR32RegClass.contains(RegImm.Reg)) + RCToScavenge = &RISCV::FPR32CRegClass; + else if (RISCV::FPR64RegClass.contains(RegImm.Reg)) + RCToScavenge = &RISCV::FPR64CRegClass; + else + return RISCV::NoRegister; + + return RS.scavengeRegisterBackwards(*RCToScavenge, FirstMI.getIterator(), + /*RestoreAfter=*/false, /*SPAdj=*/0, + /*AllowSpill=*/false); +} + +// Update uses of the old register in the given instruction to the new register. +// Return false if no further instructions should be updated. +static bool updateOperands(MachineInstr &MI, RegImmPair OldRegImm, + Register NewReg) { + bool UpdatesAllowed = true; + unsigned Opcode = MI.getOpcode(); + + // If this pass is extended to support more instructions, the check for + // definedness may need to be strengthened. + assert((compressibleLoad(Opcode) || compressibleStore(Opcode)) && + "Unsupported instruction for this optimization."); + + // Update registers + for (MachineOperand &MO : MI.operands()) + if (MO.isReg() && MO.getReg() == OldRegImm.Reg) { + // Do not update operands that define the old register. + if (MO.isDef()) { + assert(compressibleLoad(Opcode)); + // Don't allow any more updates after optimizing a load where + // OldRegImm.Reg is defined and don't update this register. + UpdatesAllowed = false; + continue; + } + // Update reg + MO.setReg(NewReg); + } + + // Update offset + MachineOperand &MOImm = MI.getOperand(2); + int64_t NewOffset = MOImm.getImm() & compressedLDSTOffsetMask(Opcode); + MOImm.setImm(NewOffset); + + return UpdatesAllowed; +} + +bool RISCVCompressInstrsOpt::runOnMachineFunction(MachineFunction &Fn) { + // This is a size optimization. + if (skipFunction(Fn.getFunction()) || !Fn.getFunction().hasOptSize()) + return false; + + const RISCVSubtarget &STI = Fn.getSubtarget(); + const RISCVInstrInfo &TII = *STI.getInstrInfo(); + + // This optimization only makes sense if compressed instructions are emitted. + if (!STI.hasStdExtC()) + return false; + + for (MachineBasicBlock &MBB : Fn) { + LLVM_DEBUG(dbgs() << "MBB: " << MBB.getName() << "\n"); + for (MachineInstr &MI : MBB) { + // Determine if this instruction would otherwise be compressed if not for + // an uncompressible register or offset. + RegImmPair RegImm = getRegImmPairPreventingCompression(MI); + if (!RegImm.Reg && RegImm.Imm == 0) + continue; + + // Determine if there is a set of instructions for which replacing this + // register with a compressed register (and compressible offset if + // applicable) is possible and will allow compression. + SmallVector MIs; + Register NewReg = analyzeCompressibleUses(MBB, MI, RegImm, MIs); + if (!NewReg) + continue; + + assert(isInt<12>(RegImm.Imm)); + BuildMI(MBB, MI, MI.getDebugLoc(), TII.get(RISCV::ADDI), NewReg) + .addReg(RegImm.Reg) + .addImm(RegImm.Imm); + + // Update the set of instructions to use the compressed register and + // compressible offset instead. These instructions should now be + // compressible. + for (MachineInstr *UpdateMI : MIs) + if (!updateOperands(*UpdateMI, RegImm, NewReg)) + break; + } + } + return true; +} + +/// Returns an instance of the Compress Instructions Optimization pass. +FunctionPass *llvm::createRISCVCompressInstrsOptPass() { + return new RISCVCompressInstrsOpt(); +} Index: llvm/lib/Target/RISCV/RISCVTargetMachine.cpp =================================================================== --- llvm/lib/Target/RISCV/RISCVTargetMachine.cpp +++ llvm/lib/Target/RISCV/RISCVTargetMachine.cpp @@ -37,6 +37,7 @@ RegisterTargetMachine Y(getTheRISCV64Target()); auto *PR = PassRegistry::getPassRegistry(); initializeGlobalISel(*PR); + initializeRISCVCompressInstrsOptPass(*PR); initializeRISCVGatherScatterLoweringPass(*PR); initializeRISCVMergeBaseOffsetOptPass(*PR); initializeRISCVExpandPseudoPass(*PR); @@ -184,7 +185,10 @@ void RISCVPassConfig::addPreSched2() {} -void RISCVPassConfig::addPreEmitPass() { addPass(&BranchRelaxationPassID); } +void RISCVPassConfig::addPreEmitPass() { + addPass(&BranchRelaxationPassID); + addPass(createRISCVCompressInstrsOptPass()); +} void RISCVPassConfig::addPreEmitPass2() { addPass(createRISCVExpandPseudoPass()); Index: llvm/test/CodeGen/RISCV/compress-instrs-i32-f-d.mir =================================================================== --- /dev/null +++ llvm/test/CodeGen/RISCV/compress-instrs-i32-f-d.mir @@ -0,0 +1,717 @@ +# RUN: llc -o - %s -mtriple=riscv32 -mattr=+c -simplify-mir \ +# RUN: -run-pass=riscv-compress-instrs | FileCheck %s +# RUN: llc -o - %s -mtriple=riscv64 -mattr=+c -simplify-mir \ +# RUN: -run-pass=riscv-compress-instrs | FileCheck %s +--- | + define void @store_common_value(i32* %a, i32* %b, i32* %c) #0 { + entry: + store i32 0, i32* %a, align 4 + store i32 0, i32* %b, align 4 + store i32 0, i32* %c, align 4 + ret void + } + + define void @store_common_value_float(float* %a, float* %b, float* %c, float %d) #0 { + entry: + store float %d, float* %a, align 4 + store float %d, float* %b, align 4 + store float %d, float* %c, align 4 + ret void + } + + define void @store_common_value_double(double* %a, double* %b, double* %c, double %d) #0 { + entry: + store double %d, double* %a, align 4 + store double %d, double* %b, align 4 + store double %d, double* %c, align 4 + ret void + } + + define void @store_common_ptr() #0 { + entry: + store volatile i32 1, i32* null, align 4 + store volatile i32 3, i32* null, align 4 + store volatile i32 5, i32* null, align 4 + ret void + } + + define void @store_common_ptr_float(float %a, float %b, float %c) #0 { + entry: + store volatile float %a, float* null, align 4 + store volatile float %b, float* null, align 4 + store volatile float %c, float* null, align 4 + ret void + } + + define void @store_common_ptr_double(double %a, double %b, double %c) #0 { + entry: + store volatile double %a, double* null, align 4 + store volatile double %b, double* null, align 4 + store volatile double %c, double* null, align 4 + ret void + } + + define void @load_common_ptr() #0 { + entry: + %a = load volatile i32, i32* null, align 4 + %b = load volatile i32, i32* null, align 4 + %c = load volatile i32, i32* null, align 4 + ret void + } + + define void @load_common_ptr_float() #0 { + entry: + %a = load volatile float, float* null, align 4 + %b = load volatile float, float* null, align 4 + %c = load volatile float, float* null, align 4 + ret void + } + + define void @load_common_ptr_double() #0 { + entry: + %a = load volatile double, double* null, align 4 + %b = load volatile double, double* null, align 4 + %c = load volatile double, double* null, align 4 + ret void + } + + define void @store_large_offset() #0 { + entry: + store volatile i32 1, i32* inttoptr (i32 305421696 to i32*), align 4 + store volatile i32 3, i32* inttoptr (i32 305421700 to i32*), align 4 + store volatile i32 5, i32* inttoptr (i32 305421704 to i32*), align 4 + store volatile i32 7, i32* inttoptr (i32 305421708 to i32*), align 4 + ret void + } + + define void @store_large_offset_float(float %a, float %b, float %c, float %d) #0 { + entry: + store volatile float %a, float* inttoptr (i32 305421696 to float*), align 4 + store volatile float %b, float* inttoptr (i32 305421700 to float*), align 4 + store volatile float %c, float* inttoptr (i32 305421704 to float*), align 4 + store volatile float %d, float* inttoptr (i32 305421708 to float*), align 4 + ret void + } + + define void @store_large_offset_double(double %a, double %b, double %c, double %d) #0 { + entry: + store volatile double %a, double* inttoptr (i32 305421696 to double*), align 4 + store volatile double %b, double* inttoptr (i32 305421700 to double*), align 4 + store volatile double %c, double* inttoptr (i32 305421704 to double*), align 4 + store volatile double %d, double* inttoptr (i32 305421708 to double*), align 4 + ret void + } + + define void @load_large_offset() #0 { + entry: + %a = load volatile i32, i32* inttoptr (i32 305421696 to i32*), align 4 + %b = load volatile i32, i32* inttoptr (i32 305421700 to i32*), align 4 + %c = load volatile i32, i32* inttoptr (i32 305421704 to i32*), align 4 + %d = load volatile i32, i32* inttoptr (i32 305421708 to i32*), align 4 + ret void + } + + define void @load_large_offset_float() #0 { + entry: + %a = load volatile float, float* inttoptr (i32 305421696 to float*), align 4 + %b = load volatile float, float* inttoptr (i32 305421700 to float*), align 4 + %c = load volatile float, float* inttoptr (i32 305421704 to float*), align 4 + %d = load volatile float, float* inttoptr (i32 305421708 to float*), align 4 + ret void + } + + define void @load_large_offset_double() #0 { + entry: + %a = load volatile double, double* inttoptr (i32 305421696 to double*), align 4 + %b = load volatile double, double* inttoptr (i32 305421700 to double*), align 4 + %c = load volatile double, double* inttoptr (i32 305421704 to double*), align 4 + %d = load volatile double, double* inttoptr (i32 305421708 to double*), align 4 + ret void + } + + define void @store_common_value_no_opt(i32* %a) #0 { + entry: + store i32 0, i32* %a, align 4 + ret void + } + + define void @store_common_value_float_no_opt(float* %a, float %b) #0 { + entry: + store float %b, float* %a, align 4 + ret void + } + + define void @store_common_value_double_no_opt(double* %a, double %b) #0 { + entry: + store double %b, double* %a, align 4 + ret void + } + + define void @store_common_ptr_no_opt() #0 { + entry: + store volatile i32 1, i32* null, align 4 + ret void + } + + define void @store_common_ptr_float_no_opt(float %a) #0 { + entry: + store volatile float %a, float* null, align 4 + ret void + } + + define void @store_common_ptr_double_no_opt(double %a) #0 { + entry: + store volatile double %a, double* null, align 4 + ret void + } + + define void @load_common_ptr_no_opt() #0 { + entry: + %a = load volatile i32, i32* null, align 4 + ret void + } + + define void @load_common_ptr_float_no_opt() #0 { + entry: + %a = load volatile float, float* null, align 4 + ret void + } + + define void @load_common_ptr_double_no_opt() #0 { + entry: + %a = load volatile double, double* null, align 4 + ret void + } + + define void @store_large_offset_no_opt() #0 { + entry: + store volatile i32 1, i32* inttoptr (i32 305421696 to i32*), align 4 + store volatile i32 3, i32* inttoptr (i32 305421700 to i32*), align 4 + ret void + } + + define void @store_large_offset_float_no_opt(float %a, float %b) #0 { + entry: + store volatile float %a, float* inttoptr (i32 305421696 to float*), align 4 + store volatile float %b, float* inttoptr (i32 305421700 to float*), align 4 + ret void + } + + define void @store_large_offset_double_no_opt(double %a, double %b) #0 { + entry: + store volatile double %a, double* inttoptr (i32 305421696 to double*), align 4 + store volatile double %b, double* inttoptr (i32 305421700 to double*), align 4 + ret void + } + + define void @load_large_offset_no_opt() #0 { + entry: + %a = load volatile i32, i32* inttoptr (i32 305421696 to i32*), align 4 + %b = load volatile i32, i32* inttoptr (i32 305421700 to i32*), align 4 + ret void + } + + define void @load_large_offset_float_no_opt() #0 { + entry: + %a = load volatile float, float* inttoptr (i32 305421696 to float*), align 4 + %b = load volatile float, float* inttoptr (i32 305421700 to float*), align 4 + ret void + } + + define void @load_large_offset_double_no_opt() #0 { + entry: + %a = load volatile double, double* inttoptr (i32 305421696 to double*), align 4 + %b = load volatile double, double* inttoptr (i32 305421700 to double*), align 4 + ret void + } + + attributes #0 = { optsize "target-features"="+c" } + +... +--- +name: store_common_value +tracksRegLiveness: true +body: | + bb.0.entry: + liveins: $x10, $x11, $x12 + ; CHECK-LABEL: name: store_common_value + ; CHECK: $x13 = ADDI $x0, 0 + ; CHECK-NEXT: SW $x13, killed renamable $x10, 0 :: (store (s32) into %ir.a) + ; CHECK-NEXT: SW $x13, killed renamable $x11, 0 :: (store (s32) into %ir.b) + ; CHECK-NEXT: SW $x13, killed renamable $x12, 0 :: (store (s32) into %ir.c) + SW $x0, killed renamable $x10, 0 :: (store (s32) into %ir.a) + SW $x0, killed renamable $x11, 0 :: (store (s32) into %ir.b) + SW $x0, killed renamable $x12, 0 :: (store (s32) into %ir.c) + PseudoRET + +... +--- +name: store_common_value_float +tracksRegLiveness: true +body: | + bb.0.entry: + liveins: $x10, $x11, $x12, $f0_f + ; CHECK-LABEL: name: store_common_value_float + ; CHECK: $f10_f = ADDI $f0_f, 0 + ; CHECK-NEXT: FSW $f10_f, killed renamable $x10, 0 :: (store (s32) into %ir.a) + ; CHECK-NEXT: FSW $f10_f, killed renamable $x11, 0 :: (store (s32) into %ir.b) + ; CHECK-NEXT: FSW $f10_f, killed renamable $x12, 0 :: (store (s32) into %ir.c) + FSW $f0_f, killed renamable $x10, 0 :: (store (s32) into %ir.a) + FSW $f0_f, killed renamable $x11, 0 :: (store (s32) into %ir.b) + FSW $f0_f, killed renamable $x12, 0 :: (store (s32) into %ir.c) + PseudoRET + +... +--- +name: store_common_value_double +tracksRegLiveness: true +body: | + bb.0.entry: + liveins: $x10, $x11, $x12, $f0_d + ; CHECK-LABEL: name: store_common_value + ; CHECK: $f10_d = ADDI $f0_d, 0 + ; CHECK-NEXT: FSD $f10_d, killed renamable $x10, 0 :: (store (s64) into %ir.a) + ; CHECK-NEXT: FSD $f10_d, killed renamable $x11, 0 :: (store (s64) into %ir.b) + ; CHECK-NEXT: FSD $f10_d, killed renamable $x12, 0 :: (store (s64) into %ir.c) + FSD $f0_d, killed renamable $x10, 0 :: (store (s64) into %ir.a) + FSD $f0_d, killed renamable $x11, 0 :: (store (s64) into %ir.b) + FSD $f0_d, killed renamable $x12, 0 :: (store (s64) into %ir.c) + PseudoRET + +... +--- +name: store_common_ptr +tracksRegLiveness: true +body: | + bb.0.entry: + ; CHECK-LABEL: name: store_common_ptr + ; CHECK: renamable $x10 = ADDI $x0, 1 + ; CHECK-NEXT: $x11 = ADDI $x0, 0 + ; CHECK-NEXT: SW killed renamable $x10, $x11, 0 :: (volatile store (s32) into `i32* null`) + ; CHECK-NEXT: renamable $x10 = ADDI $x0, 3 + ; CHECK-NEXT: SW killed renamable $x10, $x11, 0 :: (volatile store (s32) into `i32* null`) + ; CHECK-NEXT: renamable $x10 = ADDI $x0, 5 + ; CHECK-NEXT: SW killed renamable $x10, $x11, 0 :: (volatile store (s32) into `i32* null`) + renamable $x10 = ADDI $x0, 1 + SW killed renamable $x10, $x0, 0 :: (volatile store (s32) into `i32* null`) + renamable $x10 = ADDI $x0, 3 + SW killed renamable $x10, $x0, 0 :: (volatile store (s32) into `i32* null`) + renamable $x10 = ADDI $x0, 5 + SW killed renamable $x10, $x0, 0 :: (volatile store (s32) into `i32* null`) + PseudoRET + +... +--- +name: store_common_ptr_float +tracksRegLiveness: true +body: | + bb.0.entry: + liveins: $f10_f, $f11_f, $f12_f + ; CHECK-LABEL: name: store_common_ptr_float + ; CHECK: $x10 = ADDI $x0, 0 + ; CHECK-NEXT: FSW killed renamable $f10_f, $x10, 0 :: (volatile store (s32) into `float* null`) + ; CHECK-NEXT: FSW killed renamable $f11_f, $x10, 0 :: (volatile store (s32) into `float* null`) + ; CHECK-NEXT: FSW killed renamable $f12_f, $x10, 0 :: (volatile store (s32) into `float* null`) + FSW killed renamable $f10_f, $x0, 0 :: (volatile store (s32) into `float* null`) + FSW killed renamable $f11_f, $x0, 0 :: (volatile store (s32) into `float* null`) + FSW killed renamable $f12_f, $x0, 0 :: (volatile store (s32) into `float* null`) + PseudoRET + +... +--- +name: store_common_ptr_double +tracksRegLiveness: true +body: | + bb.0.entry: + liveins: $f10_d, $f11_d, $f12_d + ; CHECK-LABEL: name: store_common_ptr_double + ; CHECK: $x10 = ADDI $x0, 0 + ; CHECK-NEXT: FSD killed renamable $f10_d, $x10, 0 :: (volatile store (s64) into `double* null`) + ; CHECK-NEXT: FSD killed renamable $f11_d, $x10, 0 :: (volatile store (s64) into `double* null`) + ; CHECK-NEXT: FSD killed renamable $f12_d, $x10, 0 :: (volatile store (s64) into `double* null`) + FSD killed renamable $f10_d, $x0, 0 :: (volatile store (s64) into `double* null`) + FSD killed renamable $f11_d, $x0, 0 :: (volatile store (s64) into `double* null`) + FSD killed renamable $f12_d, $x0, 0 :: (volatile store (s64) into `double* null`) + PseudoRET + +... +--- +name: load_common_ptr +tracksRegLiveness: true +body: | + bb.0.entry: + ; CHECK-LABEL: name: load_common_ptr + ; CHECK: $x11 = ADDI $x0, 0 + ; CHECK-NEXT: dead renamable $x10 = LW $x11, 0 :: (volatile load (s32) from `i32* null`) + ; CHECK-NEXT: dead renamable $x10 = LW $x11, 0 :: (volatile load (s32) from `i32* null`) + ; CHECK-NEXT: dead renamable $x10 = LW $x11, 0 :: (volatile load (s32) from `i32* null`) + dead renamable $x10 = LW $x0, 0 :: (volatile load (s32) from `i32* null`) + dead renamable $x10 = LW $x0, 0 :: (volatile load (s32) from `i32* null`) + dead renamable $x10 = LW $x0, 0 :: (volatile load (s32) from `i32* null`) + PseudoRET + +... +--- +name: load_common_ptr_float +tracksRegLiveness: true +body: | + bb.0.entry: + ; CHECK-LABEL: name: load_common_ptr_float + ; CHECK: $x10 = ADDI $x0, 0 + ; CHECK-NEXT: dead renamable $f10_f = FLW $x10, 0 :: (volatile load (s32) from `float* null`) + ; CHECK-NEXT: dead renamable $f10_f = FLW $x10, 0 :: (volatile load (s32) from `float* null`) + ; CHECK-NEXT: dead renamable $f10_f = FLW $x10, 0 :: (volatile load (s32) from `float* null`) + dead renamable $f10_f = FLW $x0, 0 :: (volatile load (s32) from `float* null`) + dead renamable $f10_f = FLW $x0, 0 :: (volatile load (s32) from `float* null`) + dead renamable $f10_f = FLW $x0, 0 :: (volatile load (s32) from `float* null`) + PseudoRET + +... +--- +name: load_common_ptr_double +tracksRegLiveness: true +body: | + bb.0.entry: + ; CHECK-LABEL: name: load_common_ptr_double + ; CHECK: $x10 = ADDI $x0, 0 + ; CHECK-NEXT: dead renamable $f10_d = FLD $x10, 0 :: (volatile load (s64) from `double* null`) + ; CHECK-NEXT: dead renamable $f10_d = FLD $x10, 0 :: (volatile load (s64) from `double* null`) + ; CHECK-NEXT: dead renamable $f10_d = FLD $x10, 0 :: (volatile load (s64) from `double* null`) + dead renamable $f10_d = FLD $x0, 0 :: (volatile load (s64) from `double* null`) + dead renamable $f10_d = FLD $x0, 0 :: (volatile load (s64) from `double* null`) + dead renamable $f10_d = FLD $x0, 0 :: (volatile load (s64) from `double* null`) + PseudoRET + +... +--- +name: store_large_offset +tracksRegLiveness: true +body: | + bb.0.entry: + ; CHECK-LABEL: name: store_large_offset + ; CHECK: renamable $x10 = LUI 74566 + ; CHECK-NEXT: renamable $x11 = ADDI $x0, 1 + ; CHECK-NEXT: $x12 = ADDI $x10, -640 + ; CHECK-NEXT: SW killed renamable $x11, $x12, 0 :: (volatile store (s32) into `i32* inttoptr (i32 305421696 to i32*)`) + ; CHECK-NEXT: renamable $x11 = ADDI $x0, 3 + ; CHECK-NEXT: SW killed renamable $x11, $x12, 4 :: (volatile store (s32) into `i32* inttoptr (i32 305421700 to i32*)`) + ; CHECK-NEXT: renamable $x11 = ADDI $x0, 5 + ; CHECK-NEXT: SW killed renamable $x11, $x12, 8 :: (volatile store (s32) into `i32* inttoptr (i32 305421704 to i32*)`) + ; CHECK-NEXT: renamable $x11 = ADDI $x0, 7 + ; CHECK-NEXT: SW killed renamable $x11, killed $x12, 12 :: (volatile store (s32) into `i32* inttoptr (i32 305421708 to i32*)`) + renamable $x10 = LUI 74566 + renamable $x11 = ADDI $x0, 1 + SW killed renamable $x11, renamable $x10, -640 :: (volatile store (s32) into `i32* inttoptr (i32 305421696 to i32*)`) + renamable $x11 = ADDI $x0, 3 + SW killed renamable $x11, renamable $x10, -636 :: (volatile store (s32) into `i32* inttoptr (i32 305421700 to i32*)`) + renamable $x11 = ADDI $x0, 5 + SW killed renamable $x11, renamable $x10, -632 :: (volatile store (s32) into `i32* inttoptr (i32 305421704 to i32*)`) + renamable $x11 = ADDI $x0, 7 + SW killed renamable $x11, killed renamable $x10, -628 :: (volatile store (s32) into `i32* inttoptr (i32 305421708 to i32*)`) + PseudoRET + +... +--- +name: store_large_offset_float +tracksRegLiveness: true +body: | + bb.0.entry: + liveins: $f10_f, $f11_f, $f12_f, $f13_f + ; CHECK-LABEL: name: store_large_offset_float + ; CHECK: renamable $x10 = LUI 74566 + ; CHECK-NEXT: $x11 = ADDI $x10, -640 + ; CHECK-NEXT: FSW killed renamable $f10_f, $x11, 0 :: (volatile store (s32) into `float* inttoptr (i32 305421696 to float*)`) + ; CHECK-NEXT: FSW killed renamable $f11_f, $x11, 4 :: (volatile store (s32) into `float* inttoptr (i32 305421700 to float*)`) + ; CHECK-NEXT: FSW killed renamable $f12_f, $x11, 8 :: (volatile store (s32) into `float* inttoptr (i32 305421704 to float*)`) + ; CHECK-NEXT: FSW killed renamable $f13_f, killed $x11, 12 :: (volatile store (s32) into `float* inttoptr (i32 305421708 to float*)`) + renamable $x10 = LUI 74566 + FSW killed renamable $f10_f, renamable $x10, -640 :: (volatile store (s32) into `float* inttoptr (i32 305421696 to float*)`) + FSW killed renamable $f11_f, renamable $x10, -636 :: (volatile store (s32) into `float* inttoptr (i32 305421700 to float*)`) + FSW killed renamable $f12_f, renamable $x10, -632 :: (volatile store (s32) into `float* inttoptr (i32 305421704 to float*)`) + FSW killed renamable $f13_f, killed renamable $x10, -628 :: (volatile store (s32) into `float* inttoptr (i32 305421708 to float*)`) + PseudoRET + +... +--- +name: store_large_offset_double +tracksRegLiveness: true +body: | + bb.0.entry: + liveins: $f10_d, $f11_d, $f12_d, $f13_d + ; CHECK-LABEL: name: store_large_offset_double + ; CHECK: renamable $x10 = LUI 74566 + ; CHECK-NEXT: $x11 = ADDI $x10, -768 + ; CHECK-NEXT: FSD killed renamable $f10_d, $x11, 128 :: (volatile store (s64) into `double* inttoptr (i32 305421696 to double*)`) + ; CHECK-NEXT: FSD killed renamable $f11_d, $x11, 136 :: (volatile store (s64) into `double* inttoptr (i32 305421700 to double*)`) + ; CHECK-NEXT: FSD killed renamable $f12_d, $x11, 144 :: (volatile store (s64) into `double* inttoptr (i32 305421704 to double*)`) + ; CHECK-NEXT: FSD killed renamable $f13_d, killed $x11, 152 :: (volatile store (s64) into `double* inttoptr (i32 305421708 to double*)`) + renamable $x10 = LUI 74566 + FSD killed renamable $f10_d, renamable $x10, -640 :: (volatile store (s64) into `double* inttoptr (i32 305421696 to double*)`) + FSD killed renamable $f11_d, renamable $x10, -632 :: (volatile store (s64) into `double* inttoptr (i32 305421700 to double*)`) + FSD killed renamable $f12_d, renamable $x10, -624 :: (volatile store (s64) into `double* inttoptr (i32 305421704 to double*)`) + FSD killed renamable $f13_d, killed renamable $x10, -616 :: (volatile store (s64) into `double* inttoptr (i32 305421708 to double*)`) + PseudoRET + +... +--- +name: load_large_offset +tracksRegLiveness: true +body: | + bb.0.entry: + ; CHECK-LABEL: name: load_large_offset + ; CHECK: renamable $x10 = LUI 74566 + ; CHECK-NEXT: $x12 = ADDI $x10, -640 + ; CHECK-NEXT: dead renamable $x11 = LW $x12, 0 :: (volatile load (s32) from `i32* inttoptr (i32 305421696 to i32*)`) + ; CHECK-NEXT: dead renamable $x11 = LW $x12, 4 :: (volatile load (s32) from `i32* inttoptr (i32 305421700 to i32*)`) + ; CHECK-NEXT: dead renamable $x11 = LW $x12, 8 :: (volatile load (s32) from `i32* inttoptr (i32 305421704 to i32*)`) + ; CHECK-NEXT: dead renamable $x10 = LW killed $x12, 12 :: (volatile load (s32) from `i32* inttoptr (i32 305421708 to i32*)`) + renamable $x10 = LUI 74566 + dead renamable $x11 = LW renamable $x10, -640 :: (volatile load (s32) from `i32* inttoptr (i32 305421696 to i32*)`) + dead renamable $x11 = LW renamable $x10, -636 :: (volatile load (s32) from `i32* inttoptr (i32 305421700 to i32*)`) + dead renamable $x11 = LW renamable $x10, -632 :: (volatile load (s32) from `i32* inttoptr (i32 305421704 to i32*)`) + dead renamable $x10 = LW killed renamable $x10, -628 :: (volatile load (s32) from `i32* inttoptr (i32 305421708 to i32*)`) + PseudoRET + +... +--- +name: load_large_offset_float +tracksRegLiveness: true +body: | + bb.0.entry: + ; CHECK-LABEL: name: load_large_offset_float + ; CHECK: renamable $x10 = LUI 74566 + ; CHECK-NEXT: $x11 = ADDI $x10, -640 + ; CHECK-NEXT: dead renamable $f10_f = FLW $x11, 0 :: (volatile load (s32) from `float* inttoptr (i32 305421696 to float*)`) + ; CHECK-NEXT: dead renamable $f10_f = FLW $x11, 4 :: (volatile load (s32) from `float* inttoptr (i32 305421700 to float*)`) + ; CHECK-NEXT: dead renamable $f10_f = FLW $x11, 8 :: (volatile load (s32) from `float* inttoptr (i32 305421704 to float*)`) + ; CHECK-NEXT: dead renamable $f10_f = FLW killed $x11, 12 :: (volatile load (s32) from `float* inttoptr (i32 305421708 to float*)`) + renamable $x10 = LUI 74566 + dead renamable $f10_f = FLW renamable $x10, -640 :: (volatile load (s32) from `float* inttoptr (i32 305421696 to float*)`) + dead renamable $f10_f = FLW renamable $x10, -636 :: (volatile load (s32) from `float* inttoptr (i32 305421700 to float*)`) + dead renamable $f10_f = FLW renamable $x10, -632 :: (volatile load (s32) from `float* inttoptr (i32 305421704 to float*)`) + dead renamable $f10_f = FLW killed renamable $x10, -628 :: (volatile load (s32) from `float* inttoptr (i32 305421708 to float*)`) + PseudoRET + +... +--- +name: load_large_offset_double +tracksRegLiveness: true +body: | + bb.0.entry: + ; CHECK-LABEL: name: load_large_offset_double + ; CHECK: renamable $x10 = LUI 74566 + ; CHECK-NEXT: $x11 = ADDI $x10, -768 + ; CHECK-NEXT: dead renamable $f10_d = FLD $x11, 128 :: (volatile load (s64) from `double* inttoptr (i32 305421696 to double*)`) + ; CHECK-NEXT: dead renamable $f10_d = FLD $x11, 136 :: (volatile load (s64) from `double* inttoptr (i32 305421700 to double*)`) + ; CHECK-NEXT: dead renamable $f10_d = FLD $x11, 144 :: (volatile load (s64) from `double* inttoptr (i32 305421704 to double*)`) + ; CHECK-NEXT: dead renamable $f10_d = FLD killed $x11, 152 :: (volatile load (s64) from `double* inttoptr (i32 305421708 to double*)`) + renamable $x10 = LUI 74566 + dead renamable $f10_d = FLD renamable $x10, -640 :: (volatile load (s64) from `double* inttoptr (i32 305421696 to double*)`) + dead renamable $f10_d = FLD renamable $x10, -632 :: (volatile load (s64) from `double* inttoptr (i32 305421700 to double*)`) + dead renamable $f10_d = FLD renamable $x10, -624 :: (volatile load (s64) from `double* inttoptr (i32 305421704 to double*)`) + dead renamable $f10_d = FLD killed renamable $x10, -616 :: (volatile load (s64) from `double* inttoptr (i32 305421708 to double*)`) + PseudoRET + +... +--- +name: store_common_value_no_opt +tracksRegLiveness: true +body: | + bb.0.entry: + liveins: $x10 + ; CHECK-LABEL: name: store_common_value_no_opt + ; CHECK: SW $x0, killed renamable $x10, 0 :: (store (s32) into %ir.a) + SW $x0, killed renamable $x10, 0 :: (store (s32) into %ir.a) + PseudoRET + +... +--- +name: store_common_value_float_no_opt +tracksRegLiveness: true +body: | + bb.0.entry: + liveins: $x10, $f0_f + ; CHECK-LABEL: name: store_common_value_float_no_opt + ; CHECK: FSW $f0_f, killed renamable $x10, 0 :: (store (s32) into %ir.a) + FSW $f0_f, killed renamable $x10, 0 :: (store (s32) into %ir.a) + PseudoRET + +... +--- +name: store_common_value_double_no_opt +tracksRegLiveness: true +body: | + bb.0.entry: + liveins: $x10, $f0_d + ; CHECK-LABEL: name: store_common_value_double_no_opt + ; CHECK: FSD $f0_d, killed renamable $x10, 0 :: (store (s64) into %ir.a) + FSD $f0_d, killed renamable $x10, 0 :: (store (s64) into %ir.a) + PseudoRET + +... +--- +name: store_common_ptr_no_opt +tracksRegLiveness: true +body: | + bb.0.entry: + ; CHECK-LABEL: name: store_common_ptr_no_opt + ; CHECK: renamable $x10 = ADDI $x0, 1 + ; CHECK-NEXT: SW killed renamable $x10, $x0, 0 :: (volatile store (s32) into `i32* null`) + renamable $x10 = ADDI $x0, 1 + SW killed renamable $x10, $x0, 0 :: (volatile store (s32) into `i32* null`) + PseudoRET + +... +--- +name: store_common_ptr_float_no_opt +tracksRegLiveness: true +body: | + bb.0.entry: + liveins: $f10_f + ; CHECK-LABEL: name: store_common_ptr_float_no_opt + ; CHECK: FSW killed renamable $f10_f, $x0, 0 :: (volatile store (s32) into `float* null`) + FSW killed renamable $f10_f, $x0, 0 :: (volatile store (s32) into `float* null`) + PseudoRET + +... +--- +name: store_common_ptr_double_no_opt +tracksRegLiveness: true +body: | + bb.0.entry: + liveins: $f10_d + ; CHECK-LABEL: name: store_common_ptr_double_no_opt + ; CHECK: FSD killed renamable $f10_d, $x0, 0 :: (volatile store (s64) into `double* null`) + FSD killed renamable $f10_d, $x0, 0 :: (volatile store (s64) into `double* null`) + PseudoRET + +... +--- +name: load_common_ptr_no_opt +tracksRegLiveness: true +body: | + bb.0.entry: + ; CHECK-LABEL: name: load_common_ptr_no_opt + ; CHECK: dead renamable $x10 = LW $x0, 0 :: (volatile load (s32) from `i32* null`) + dead renamable $x10 = LW $x0, 0 :: (volatile load (s32) from `i32* null`) + PseudoRET + +... +--- +name: load_common_ptr_float_no_opt +tracksRegLiveness: true +body: | + bb.0.entry: + ; CHECK-LABEL: name: load_common_ptr_float_no_opt + ; CHECK: dead renamable $f10_f = FLW $x0, 0 :: (volatile load (s32) from `float* null`) + dead renamable $f10_f = FLW $x0, 0 :: (volatile load (s32) from `float* null`) + PseudoRET + +... +--- +name: load_common_ptr_double_no_opt +tracksRegLiveness: true +body: | + bb.0.entry: + ; CHECK-LABEL: name: load_common_ptr_double_no_opt + ; CHECK: dead renamable $f10_d = FLD $x0, 0 :: (volatile load (s64) from `double* null`) + dead renamable $f10_d = FLD $x0, 0 :: (volatile load (s64) from `double* null`) + PseudoRET + +... +--- +name: store_large_offset_no_opt +tracksRegLiveness: true +body: | + bb.0.entry: + ; CHECK-LABEL: name: store_large_offset_no_opt + ; CHECK: renamable $x10 = LUI 74566 + ; CHECK-NEXT: renamable $x11 = ADDI $x0, 1 + ; CHECK-NEXT: SW killed renamable $x11, renamable $x10, -640 :: (volatile store (s32) into `i32* inttoptr (i32 305421696 to i32*)`) + ; CHECK-NEXT: renamable $x11 = ADDI $x0, 3 + ; CHECK-NEXT: SW killed renamable $x11, killed renamable $x10, -636 :: (volatile store (s32) into `i32* inttoptr (i32 305421700 to i32*)`) + renamable $x10 = LUI 74566 + renamable $x11 = ADDI $x0, 1 + SW killed renamable $x11, renamable $x10, -640 :: (volatile store (s32) into `i32* inttoptr (i32 305421696 to i32*)`) + renamable $x11 = ADDI $x0, 3 + SW killed renamable $x11, killed renamable $x10, -636 :: (volatile store (s32) into `i32* inttoptr (i32 305421700 to i32*)`) + PseudoRET + +... +--- +name: store_large_offset_float_no_opt +tracksRegLiveness: true +body: | + bb.0.entry: + liveins: $f10_f, $f11_f + ; CHECK-LABEL: name: store_large_offset_float_no_opt + ; CHECK: renamable $x10 = LUI 74566 + ; CHECK-NEXT: FSW killed renamable $f10_f, renamable $x10, -640 :: (volatile store (s32) into `float* inttoptr (i32 305421696 to float*)`) + ; CHECK-NEXT: FSW killed renamable $f11_f, killed renamable $x10, -636 :: (volatile store (s32) into `float* inttoptr (i32 305421700 to float*)`) + renamable $x10 = LUI 74566 + FSW killed renamable $f10_f, renamable $x10, -640 :: (volatile store (s32) into `float* inttoptr (i32 305421696 to float*)`) + FSW killed renamable $f11_f, killed renamable $x10, -636 :: (volatile store (s32) into `float* inttoptr (i32 305421700 to float*)`) + PseudoRET + +... +--- +name: store_large_offset_double_no_opt +tracksRegLiveness: true +body: | + bb.0.entry: + liveins: $f10_d, $f11_d + ; CHECK-LABEL: name: store_large_offset_double_no_opt + ; CHECK: renamable $x10 = LUI 74566 + ; CHECK-NEXT: FSD killed renamable $f10_d, renamable $x10, -640 :: (volatile store (s64) into `double* inttoptr (i32 305421696 to double*)`) + ; CHECK-NEXT: FSD killed renamable $f11_d, killed renamable $x10, -632 :: (volatile store (s64) into `double* inttoptr (i32 305421700 to double*)`) + renamable $x10 = LUI 74566 + FSD killed renamable $f10_d, renamable $x10, -640 :: (volatile store (s64) into `double* inttoptr (i32 305421696 to double*)`) + FSD killed renamable $f11_d, killed renamable $x10, -632 :: (volatile store (s64) into `double* inttoptr (i32 305421700 to double*)`) + PseudoRET + +... +--- +name: load_large_offset_no_opt +tracksRegLiveness: true +body: | + bb.0.entry: + ; CHECK-LABEL: name: load_large_offset_no_opt + ; CHECK: renamable $x10 = LUI 74566 + ; CHECK-NEXT: dead renamable $x11 = LW renamable $x10, -640 :: (volatile load (s32) from `i32* inttoptr (i32 305421696 to i32*)`) + ; CHECK-NEXT: dead renamable $x10 = LW killed renamable $x10, -636 :: (volatile load (s32) from `i32* inttoptr (i32 305421700 to i32*)`) + renamable $x10 = LUI 74566 + dead renamable $x11 = LW renamable $x10, -640 :: (volatile load (s32) from `i32* inttoptr (i32 305421696 to i32*)`) + dead renamable $x10 = LW killed renamable $x10, -636 :: (volatile load (s32) from `i32* inttoptr (i32 305421700 to i32*)`) + PseudoRET + +... +--- +name: load_large_offset_float_no_opt +tracksRegLiveness: true +body: | + bb.0.entry: + ; CHECK-LABEL: name: load_large_offset_float_no_opt + ; CHECK: renamable $x10 = LUI 74566 + ; CHECK-NEXT: dead renamable $f10_f = FLW renamable $x10, -640 :: (volatile load (s32) from `float* inttoptr (i32 305421696 to float*)`) + ; CHECK-NEXT: dead renamable $f10_f = FLW killed renamable $x10, -636 :: (volatile load (s32) from `float* inttoptr (i32 305421700 to float*)`) + renamable $x10 = LUI 74566 + dead renamable $f10_f = FLW renamable $x10, -640 :: (volatile load (s32) from `float* inttoptr (i32 305421696 to float*)`) + dead renamable $f10_f = FLW killed renamable $x10, -636 :: (volatile load (s32) from `float* inttoptr (i32 305421700 to float*)`) + PseudoRET + +... +--- +name: load_large_offset_double_no_opt +tracksRegLiveness: true +body: | + bb.0.entry: + ; CHECK-LABEL: name: load_large_offset_double_no_opt + ; CHECK: renamable $x10 = LUI 74566 + ; CHECK-NEXT: dead renamable $f10_d = FLD renamable $x10, -640 :: (volatile load (s64) from `double* inttoptr (i32 305421696 to double*)`) + ; CHECK-NEXT: dead renamable $f10_d = FLD killed renamable $x10, -632 :: (volatile load (s64) from `double* inttoptr (i32 305421700 to double*)`) + renamable $x10 = LUI 74566 + dead renamable $f10_d = FLD renamable $x10, -640 :: (volatile load (s64) from `double* inttoptr (i32 305421696 to double*)`) + dead renamable $f10_d = FLD killed renamable $x10, -632 :: (volatile load (s64) from `double* inttoptr (i32 305421700 to double*)`) + PseudoRET + +... Index: llvm/test/CodeGen/RISCV/compress-instrs-i64.mir =================================================================== --- /dev/null +++ llvm/test/CodeGen/RISCV/compress-instrs-i64.mir @@ -0,0 +1,253 @@ +# RUN: llc -o - %s -mtriple=riscv64 -mattr=+c -simplify-mir \ +# RUN: -run-pass=riscv-compress-instrs | FileCheck %s +--- | + define void @store_common_value(i64* %a, i64* %b, i64* %c) #0 { + entry: + store i64 0, i64* %a, align 8 + store i64 0, i64* %b, align 8 + store i64 0, i64* %c, align 8 + ret void + } + + define void @store_common_ptr() #0 { + entry: + store volatile i64 1, i64* null, align 8 + store volatile i64 3, i64* null, align 8 + store volatile i64 5, i64* null, align 8 + ret void + } + + define void @load_common_ptr() #0 { + entry: + %a = load volatile i64, i64* null, align 8 + %b = load volatile i64, i64* null, align 8 + %c = load volatile i64, i64* null, align 8 + ret void + } + + define void @store_large_offset() #0 { + entry: + store volatile i64 1, i64* inttoptr (i64 305421696 to i64*), align 8 + store volatile i64 3, i64* inttoptr (i64 305421704 to i64*), align 8 + store volatile i64 5, i64* inttoptr (i64 305421712 to i64*), align 8 + store volatile i64 7, i64* inttoptr (i64 305421720 to i64*), align 8 + ret void + } + + define void @load_large_offset() #0 { + entry: + %a = load volatile i64, i64* inttoptr (i64 305421696 to i64*), align 8 + %b = load volatile i64, i64* inttoptr (i64 305421704 to i64*), align 8 + %c = load volatile i64, i64* inttoptr (i64 305421712 to i64*), align 8 + %d = load volatile i64, i64* inttoptr (i64 305421720 to i64*), align 8 + ret void + } + + define void @store_common_value_no_opt(i64* %a) #0 { + entry: + store i64 0, i64* %a, align 8 + ret void + } + + define void @store_common_ptr_no_opt() #0 { + entry: + store volatile i64 1, i64* null, align 8 + ret void + } + + define void @load_common_ptr_no_opt() #0 { + entry: + %a = load volatile i64, i64* null, align 8 + ret void + } + + define void @store_large_offset_no_opt() #0 { + entry: + store volatile i64 1, i64* inttoptr (i64 305421696 to i64*), align 8 + store volatile i64 3, i64* inttoptr (i64 305421704 to i64*), align 8 + ret void + } + + define void @load_large_offset_no_opt() #0 { + entry: + %a = load volatile i64, i64* inttoptr (i64 305421696 to i64*), align 8 + %b = load volatile i64, i64* inttoptr (i64 305421704 to i64*), align 8 + ret void + } + + attributes #0 = { optsize "target-features"="+c" } + +... +--- +name: store_common_value +tracksRegLiveness: true +body: | + bb.0.entry: + liveins: $x10, $x11, $x12 + ; CHECK-LABEL: name: store_common_value + ; CHECK: $x13 = ADDI $x0, 0 + ; CHECK-NEXT: SD $x13, killed renamable $x10, 0 :: (store (s64) into %ir.a) + ; CHECK-NEXT: SD $x13, killed renamable $x11, 0 :: (store (s64) into %ir.b) + ; CHECK-NEXT: SD $x13, killed renamable $x12, 0 :: (store (s64) into %ir.c) + SD $x0, killed renamable $x10, 0 :: (store (s64) into %ir.a) + SD $x0, killed renamable $x11, 0 :: (store (s64) into %ir.b) + SD $x0, killed renamable $x12, 0 :: (store (s64) into %ir.c) + PseudoRET + +... +--- +name: store_common_ptr +tracksRegLiveness: true +body: | + bb.0.entry: + ; CHECK-LABEL: name: store_common_ptr + ; CHECK: renamable $x10 = ADDI $x0, 1 + ; CHECK-NEXT: $x11 = ADDI $x0, 0 + ; CHECK-NEXT: SD killed renamable $x10, $x11, 0 :: (volatile store (s64) into `i64* null`) + ; CHECK-NEXT: renamable $x10 = ADDI $x0, 3 + ; CHECK-NEXT: SD killed renamable $x10, $x11, 0 :: (volatile store (s64) into `i64* null`) + ; CHECK-NEXT: renamable $x10 = ADDI $x0, 5 + ; CHECK-NEXT: SD killed renamable $x10, $x11, 0 :: (volatile store (s64) into `i64* null`) + renamable $x10 = ADDI $x0, 1 + SD killed renamable $x10, $x0, 0 :: (volatile store (s64) into `i64* null`) + renamable $x10 = ADDI $x0, 3 + SD killed renamable $x10, $x0, 0 :: (volatile store (s64) into `i64* null`) + renamable $x10 = ADDI $x0, 5 + SD killed renamable $x10, $x0, 0 :: (volatile store (s64) into `i64* null`) + PseudoRET + +... +--- +name: load_common_ptr +tracksRegLiveness: true +body: | + bb.0.entry: + ; CHECK-LABEL: name: load_common_ptr + ; CHECK: $x11 = ADDI $x0, 0 + ; CHECK-NEXT: dead renamable $x10 = LD $x11, 0 :: (volatile load (s64) from `i64* null`) + ; CHECK-NEXT: dead renamable $x10 = LD $x11, 0 :: (volatile load (s64) from `i64* null`) + ; CHECK-NEXT: dead renamable $x10 = LD $x11, 0 :: (volatile load (s64) from `i64* null`) + dead renamable $x10 = LD $x0, 0 :: (volatile load (s64) from `i64* null`) + dead renamable $x10 = LD $x0, 0 :: (volatile load (s64) from `i64* null`) + dead renamable $x10 = LD $x0, 0 :: (volatile load (s64) from `i64* null`) + PseudoRET + +... +--- +name: store_large_offset +tracksRegLiveness: true +body: | + bb.0.entry: + ; CHECK-LABEL: name: store_large_offset + ; CHECK: renamable $x10 = LUI 74566 + ; CHECK-NEXT: renamable $x11 = ADDI $x0, 1 + ; CHECK-NEXT: $x12 = ADDI $x10, -768 + ; CHECK-NEXT: SD killed renamable $x11, $x12, 128 :: (volatile store (s64) into `i64* inttoptr (i64 305421696 to i64*)`) + ; CHECK-NEXT: renamable $x11 = ADDI $x0, 3 + ; CHECK-NEXT: SD killed renamable $x11, $x12, 136 :: (volatile store (s64) into `i64* inttoptr (i64 305421700 to i64*)`) + ; CHECK-NEXT: renamable $x11 = ADDI $x0, 5 + ; CHECK-NEXT: SD killed renamable $x11, $x12, 144 :: (volatile store (s64) into `i64* inttoptr (i64 305421704 to i64*)`) + ; CHECK-NEXT: renamable $x11 = ADDI $x0, 7 + ; CHECK-NEXT: SD killed renamable $x11, killed $x12, 152 :: (volatile store (s64) into `i64* inttoptr (i64 305421708 to i64*)`) + renamable $x10 = LUI 74566 + renamable $x11 = ADDI $x0, 1 + SD killed renamable $x11, renamable $x10, -640 :: (volatile store (s64) into `i64* inttoptr (i64 305421696 to i64*)`) + renamable $x11 = ADDI $x0, 3 + SD killed renamable $x11, renamable $x10, -632 :: (volatile store (s64) into `i64* inttoptr (i64 305421700 to i64*)`) + renamable $x11 = ADDI $x0, 5 + SD killed renamable $x11, renamable $x10, -624 :: (volatile store (s64) into `i64* inttoptr (i64 305421704 to i64*)`) + renamable $x11 = ADDI $x0, 7 + SD killed renamable $x11, killed renamable $x10, -616 :: (volatile store (s64) into `i64* inttoptr (i64 305421708 to i64*)`) + PseudoRET + +... +--- +name: load_large_offset +tracksRegLiveness: true +body: | + bb.0.entry: + ; CHECK-LABEL: name: load_large_offset + ; CHECK: renamable $x10 = LUI 74566 + ; CHECK-NEXT: $x12 = ADDI $x10, -768 + ; CHECK-NEXT: dead renamable $x11 = LD $x12, 128 :: (volatile load (s64) from `i64* inttoptr (i64 305421696 to i64*)`) + ; CHECK-NEXT: dead renamable $x11 = LD $x12, 136 :: (volatile load (s64) from `i64* inttoptr (i64 305421700 to i64*)`) + ; CHECK-NEXT: dead renamable $x11 = LD $x12, 144 :: (volatile load (s64) from `i64* inttoptr (i64 305421704 to i64*)`) + ; CHECK-NEXT: dead renamable $x10 = LD killed $x12, 152 :: (volatile load (s64) from `i64* inttoptr (i64 305421708 to i64*)`) + renamable $x10 = LUI 74566 + dead renamable $x11 = LD renamable $x10, -640 :: (volatile load (s64) from `i64* inttoptr (i64 305421696 to i64*)`) + dead renamable $x11 = LD renamable $x10, -632 :: (volatile load (s64) from `i64* inttoptr (i64 305421700 to i64*)`) + dead renamable $x11 = LD renamable $x10, -624 :: (volatile load (s64) from `i64* inttoptr (i64 305421704 to i64*)`) + dead renamable $x10 = LD killed renamable $x10, -616 :: (volatile load (s64) from `i64* inttoptr (i64 305421708 to i64*)`) + PseudoRET + +... +--- +name: store_common_value_no_opt +tracksRegLiveness: true +body: | + bb.0.entry: + liveins: $x10 + ; CHECK-LABEL: name: store_common_value_no_opt + ; CHECK: SD $x0, killed renamable $x10, 0 :: (store (s64) into %ir.a) + SD $x0, killed renamable $x10, 0 :: (store (s64) into %ir.a) + PseudoRET + +... +--- +name: store_common_ptr_no_opt +tracksRegLiveness: true +body: | + bb.0.entry: + ; CHECK-LABEL: name: store_common_ptr_no_opt + ; CHECK: renamable $x10 = ADDI $x0, 1 + ; CHECK-NEXT: SD killed renamable $x10, $x0, 0 :: (volatile store (s64) into `i64* null`) + renamable $x10 = ADDI $x0, 1 + SD killed renamable $x10, $x0, 0 :: (volatile store (s64) into `i64* null`) + PseudoRET + +... +--- +name: load_common_ptr_no_opt +tracksRegLiveness: true +body: | + bb.0.entry: + ; CHECK-LABEL: name: load_common_ptr_no_opt + ; CHECK: dead renamable $x10 = LD $x0, 0 :: (volatile load (s64) from `i64* null`) + dead renamable $x10 = LD $x0, 0 :: (volatile load (s64) from `i64* null`) + PseudoRET + +... +--- +name: store_large_offset_no_opt +tracksRegLiveness: true +body: | + bb.0.entry: + ; CHECK-LABEL: name: store_large_offset_no_opt + ; CHECK: renamable $x10 = LUI 74566 + ; CHECK-NEXT: renamable $x11 = ADDI $x0, 1 + ; CHECK-NEXT: SD killed renamable $x11, renamable $x10, -640 :: (volatile store (s64) into `i64* inttoptr (i64 305421696 to i64*)`) + ; CHECK-NEXT: renamable $x11 = ADDI $x0, 3 + ; CHECK-NEXT: SD killed renamable $x11, killed renamable $x10, -632 :: (volatile store (s64) into `i64* inttoptr (i64 305421700 to i64*)`) + renamable $x10 = LUI 74566 + renamable $x11 = ADDI $x0, 1 + SD killed renamable $x11, renamable $x10, -640 :: (volatile store (s64) into `i64* inttoptr (i64 305421696 to i64*)`) + renamable $x11 = ADDI $x0, 3 + SD killed renamable $x11, killed renamable $x10, -632 :: (volatile store (s64) into `i64* inttoptr (i64 305421700 to i64*)`) + PseudoRET + +... +--- +name: load_large_offset_no_opt +tracksRegLiveness: true +body: | + bb.0.entry: + ; CHECK-LABEL: name: load_large_offset_no_opt + ; CHECK: renamable $x10 = LUI 74566 + ; CHECK-NEXT: dead renamable $x11 = LD renamable $x10, -640 :: (volatile load (s64) from `i64* inttoptr (i64 305421696 to i64*)`) + ; CHECK-NEXT: dead renamable $x10 = LD killed renamable $x10, -632 :: (volatile load (s64) from `i64* inttoptr (i64 305421700 to i64*)`) + renamable $x10 = LUI 74566 + dead renamable $x11 = LD renamable $x10, -640 :: (volatile load (s64) from `i64* inttoptr (i64 305421696 to i64*)`) + dead renamable $x10 = LD killed renamable $x10, -632 :: (volatile load (s64) from `i64* inttoptr (i64 305421700 to i64*)`) + PseudoRET + +...