From d84aa4581664d9964ec4d63f42406d8cf8d57da6 Mon Sep 17 00:00:00 2001 From: Kuznetsov-Artyom Date: Sat, 20 Apr 2024 23:42:10 +0300 Subject: [PATCH 01/10] add pass --- llvm/lib/Target/X86/CMakeLists.txt | 1 + llvm/lib/Target/X86/X86.h | 2 + llvm/lib/Target/X86/X86MulAddPass.cpp | 67 +++++ llvm/lib/Target/X86/X86TargetMachine.cpp | 1 + llvm/test/lab3/kuznetsov_artyom/test.cpp | 14 + llvm/test/lab3/kuznetsov_artyom/test.ll | 58 ++++ llvm/test/lab3/kuznetsov_artyom/test.mir | 300 +++++++++++++++++++ llvm/test/lab3/kuznetsov_artyom/test_out.mir | 293 ++++++++++++++++++ 8 files changed, 736 insertions(+) create mode 100644 llvm/lib/Target/X86/X86MulAddPass.cpp create mode 100644 llvm/test/lab3/kuznetsov_artyom/test.cpp create mode 100644 llvm/test/lab3/kuznetsov_artyom/test.ll create mode 100644 llvm/test/lab3/kuznetsov_artyom/test.mir create mode 100644 llvm/test/lab3/kuznetsov_artyom/test_out.mir diff --git a/llvm/lib/Target/X86/CMakeLists.txt b/llvm/lib/Target/X86/CMakeLists.txt index e79bed6409315..4ab6c90c775e0 100644 --- a/llvm/lib/Target/X86/CMakeLists.txt +++ b/llvm/lib/Target/X86/CMakeLists.txt @@ -23,6 +23,7 @@ tablegen(LLVM X86GenFoldTables.inc -gen-x86-fold-tables -asmwriternum=1) add_public_tablegen_target(X86CommonTableGen) set(sources + X86MulAddPass.cpp X86ArgumentStackSlotRebase.cpp X86AsmPrinter.cpp X86AvoidTrailingCall.cpp diff --git a/llvm/lib/Target/X86/X86.h b/llvm/lib/Target/X86/X86.h index 76ecc77bc39c2..238877f104802 100644 --- a/llvm/lib/Target/X86/X86.h +++ b/llvm/lib/Target/X86/X86.h @@ -167,6 +167,7 @@ FunctionPass *createX86LoadValueInjectionRetHardeningPass(); FunctionPass *createX86SpeculativeLoadHardeningPass(); FunctionPass *createX86SpeculativeExecutionSideEffectSuppression(); FunctionPass *createX86ArgumentStackSlotPass(); +FunctionPass *createX86MulAddPassCallPass(); void initializeEvexToVexInstPassPass(PassRegistry &); void initializeFPSPass(PassRegistry &); @@ -201,6 +202,7 @@ void initializeX86ReturnThunksPass(PassRegistry &); void initializeX86SpeculativeExecutionSideEffectSuppressionPass(PassRegistry &); void initializeX86SpeculativeLoadHardeningPassPass(PassRegistry &); void initializeX86TileConfigPass(PassRegistry &); +void initializeX86MulAddPassPass(PassRegistry &); namespace X86AS { enum : unsigned { diff --git a/llvm/lib/Target/X86/X86MulAddPass.cpp b/llvm/lib/Target/X86/X86MulAddPass.cpp new file mode 100644 index 0000000000000..1a0c7e374503f --- /dev/null +++ b/llvm/lib/Target/X86/X86MulAddPass.cpp @@ -0,0 +1,67 @@ +#include "X86.h" +#include "X86InstrInfo.h" +#include "X86Subtarget.h" +#include "llvm/CodeGen/MachineFunctionPass.h" +#include "llvm/CodeGen/MachineInstrBuilder.h" + +using namespace llvm; + +#define X86_MULADD_PASS_NAME "My custom X86 muladd pass" + +namespace { +class X86MulAddPass : public MachineFunctionPass { +public: + static char ID; + + X86MulAddPass() : MachineFunctionPass(ID) { + initializeX86MulAddPassPass(*PassRegistry::getPassRegistry()); + } + + bool runOnMachineFunction(MachineFunction &MF) override; + + StringRef getPassName() const override { return X86_MULADD_PASS_NAME; } +}; + +char X86MulAddPass::ID = 0; + +bool X86MulAddPass::runOnMachineFunction(MachineFunction &MF) { + const TargetInstrInfo *TII = MF.getSubtarget().getInstrInfo(); + + for (auto &MBB : MF) { + for (auto I = MBB.begin(); I != MBB.end(); I++) { + // Found multiply operation + if (I->getOpcode() == X86::MULPDrr) { + auto MulInstr = I; + auto NextInstr = std::next(MulInstr); + // And next operation is add + if (NextInstr->getOpcode() == X86::ADDPDrr) { + if (MulInstr->getOperand(0).getReg() == NextInstr->getOperand(1).getReg()) { + I--; + MachineInstr &MI = *MulInstr; + MachineInstrBuilder MIB = BuildMI(MBB, MI, MI.getDebugLoc(), TII->get(X86::VFMADD213PDZ128r)); + MIB.addReg(NextInstr->getOperand(0).getReg(), RegState::Define); + MIB.addReg(MulInstr->getOperand(1).getReg()); + MIB.addReg(MulInstr->getOperand(2).getReg()); + MIB.addReg(NextInstr->getOperand(2).getReg()); + MulInstr->eraseFromParent(); + NextInstr->eraseFromParent(); + } + } + } + } + } + + return false; +} + +} // end of anonymous namespace + +INITIALIZE_PASS(X86MulAddPass, "x86-muladd", + X86_MULADD_PASS_NAME, + false, // is CFG only? + false // is analysis? +) + +namespace llvm { + FunctionPass *createX86MulAddPassPass() { return new X86MulAddPass(); } +} \ No newline at end of file diff --git a/llvm/lib/Target/X86/X86TargetMachine.cpp b/llvm/lib/Target/X86/X86TargetMachine.cpp index c096e6dd9686c..d8aa8b89d8f21 100644 --- a/llvm/lib/Target/X86/X86TargetMachine.cpp +++ b/llvm/lib/Target/X86/X86TargetMachine.cpp @@ -105,6 +105,7 @@ extern "C" LLVM_EXTERNAL_VISIBILITY void LLVMInitializeX86Target() { initializeX86ReturnThunksPass(PR); initializeX86DAGToDAGISelPass(PR); initializeX86ArgumentStackSlotPassPass(PR); + initializeX86MulAddPassPass(PR); } static std::unique_ptr createTLOF(const Triple &TT) { diff --git a/llvm/test/lab3/kuznetsov_artyom/test.cpp b/llvm/test/lab3/kuznetsov_artyom/test.cpp new file mode 100644 index 0000000000000..41c761ed6ef69 --- /dev/null +++ b/llvm/test/lab3/kuznetsov_artyom/test.cpp @@ -0,0 +1,14 @@ +#include + +__m128d muladd_test1(__m128d a, __m128d b, __m128d c) { return a * b + c; } + +__m128d muladd_test2(__m128d a, __m128d b, __m128d c) { + __m128d tmp = a * b; + tmp = tmp + c; + return tmp; +} + +__m128d muladd_test3(__m128d a, __m128d b, __m128d c) { + __m128d tmp = a * c + b; + return tmp * c + b; +} diff --git a/llvm/test/lab3/kuznetsov_artyom/test.ll b/llvm/test/lab3/kuznetsov_artyom/test.ll new file mode 100644 index 0000000000000..0eed142455a54 --- /dev/null +++ b/llvm/test/lab3/kuznetsov_artyom/test.ll @@ -0,0 +1,58 @@ +define dso_local noundef <2 x double> @_Z12muladd_test1Dv2_dS_S_(<2 x double> noundef %a, <2 x double> noundef %b, <2 x double> noundef %c) { +entry: + %a.addr = alloca <2 x double>, align 16 + %b.addr = alloca <2 x double>, align 16 + %c.addr = alloca <2 x double>, align 16 + store <2 x double> %a, ptr %a.addr, align 16 + store <2 x double> %b, ptr %b.addr, align 16 + store <2 x double> %c, ptr %c.addr, align 16 + %0 = load <2 x double>, ptr %a.addr, align 16 + %1 = load <2 x double>, ptr %b.addr, align 16 + %2 = load <2 x double>, ptr %c.addr, align 16 + %3 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %0, <2 x double> %1, <2 x double> %2) + ret <2 x double> %3 +} + +declare <2 x double> @llvm.fmuladd.v2f64(<2 x double>, <2 x double>, <2 x double>) + +define dso_local noundef <2 x double> @_Z12muladd_test2Dv2_dS_S_(<2 x double> noundef %a, <2 x double> noundef %b, <2 x double> noundef %c) { +entry: + %a.addr = alloca <2 x double>, align 16 + %b.addr = alloca <2 x double>, align 16 + %c.addr = alloca <2 x double>, align 16 + %tmp = alloca <2 x double>, align 16 + store <2 x double> %a, ptr %a.addr, align 16 + store <2 x double> %b, ptr %b.addr, align 16 + store <2 x double> %c, ptr %c.addr, align 16 + %0 = load <2 x double>, ptr %a.addr, align 16 + %1 = load <2 x double>, ptr %b.addr, align 16 + %mul = fmul <2 x double> %0, %1 + store <2 x double> %mul, ptr %tmp, align 16 + %2 = load <2 x double>, ptr %tmp, align 16 + %3 = load <2 x double>, ptr %c.addr, align 16 + %add = fadd <2 x double> %2, %3 + store <2 x double> %add, ptr %tmp, align 16 + %4 = load <2 x double>, ptr %tmp, align 16 + ret <2 x double> %4 +} + +define dso_local noundef <2 x double> @_Z12muladd_test3Dv2_dS_S_(<2 x double> noundef %a, <2 x double> noundef %b, <2 x double> noundef %c) { +entry: + %a.addr = alloca <2 x double>, align 16 + %b.addr = alloca <2 x double>, align 16 + %c.addr = alloca <2 x double>, align 16 + %tmp = alloca <2 x double>, align 16 + store <2 x double> %a, ptr %a.addr, align 16 + store <2 x double> %b, ptr %b.addr, align 16 + store <2 x double> %c, ptr %c.addr, align 16 + %0 = load <2 x double>, ptr %a.addr, align 16 + %1 = load <2 x double>, ptr %c.addr, align 16 + %2 = load <2 x double>, ptr %b.addr, align 16 + %3 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %0, <2 x double> %1, <2 x double> %2) + store <2 x double> %3, ptr %tmp, align 16 + %4 = load <2 x double>, ptr %tmp, align 16 + %5 = load <2 x double>, ptr %c.addr, align 16 + %6 = load <2 x double>, ptr %b.addr, align 16 + %7 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %4, <2 x double> %5, <2 x double> %6) + ret <2 x double> %7 +} \ No newline at end of file diff --git a/llvm/test/lab3/kuznetsov_artyom/test.mir b/llvm/test/lab3/kuznetsov_artyom/test.mir new file mode 100644 index 0000000000000..821e878b6cb46 --- /dev/null +++ b/llvm/test/lab3/kuznetsov_artyom/test.mir @@ -0,0 +1,300 @@ +# RUN: llc -march=x86-64 test.mir -run-pass=x86-muladd %s -o - | FileCheck %s + + +--- | + ; ModuleID = 'test.ll' + source_filename = "test.ll" + target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" + + define dso_local noundef <2 x double> @_Z12muladd_test1Dv2_dS_S_(<2 x double> noundef %a, <2 x double> noundef %b, <2 x double> noundef %c) { + entry: + %a.addr = alloca <2 x double>, align 16 + %b.addr = alloca <2 x double>, align 16 + %c.addr = alloca <2 x double>, align 16 + store <2 x double> %a, ptr %a.addr, align 16 + store <2 x double> %b, ptr %b.addr, align 16 + store <2 x double> %c, ptr %c.addr, align 16 + %0 = load <2 x double>, ptr %a.addr, align 16 + %1 = load <2 x double>, ptr %b.addr, align 16 + %2 = load <2 x double>, ptr %c.addr, align 16 + %3 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %0, <2 x double> %1, <2 x double> %2) + ret <2 x double> %3 + } + + ; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none) + declare <2 x double> @llvm.fmuladd.v2f64(<2 x double>, <2 x double>, <2 x double>) #0 + + define dso_local noundef <2 x double> @_Z12muladd_test2Dv2_dS_S_(<2 x double> noundef %a, <2 x double> noundef %b, <2 x double> noundef %c) { + entry: + %a.addr = alloca <2 x double>, align 16 + %b.addr = alloca <2 x double>, align 16 + %c.addr = alloca <2 x double>, align 16 + %tmp = alloca <2 x double>, align 16 + store <2 x double> %a, ptr %a.addr, align 16 + store <2 x double> %b, ptr %b.addr, align 16 + store <2 x double> %c, ptr %c.addr, align 16 + %0 = load <2 x double>, ptr %a.addr, align 16 + %1 = load <2 x double>, ptr %b.addr, align 16 + %mul = fmul <2 x double> %0, %1 + store <2 x double> %mul, ptr %tmp, align 16 + %2 = load <2 x double>, ptr %tmp, align 16 + %3 = load <2 x double>, ptr %c.addr, align 16 + %add = fadd <2 x double> %2, %3 + store <2 x double> %add, ptr %tmp, align 16 + %4 = load <2 x double>, ptr %tmp, align 16 + ret <2 x double> %4 + } + + define dso_local noundef <2 x double> @_Z12muladd_test3Dv2_dS_S_(<2 x double> noundef %a, <2 x double> noundef %b, <2 x double> noundef %c) { + entry: + %a.addr = alloca <2 x double>, align 16 + %b.addr = alloca <2 x double>, align 16 + %c.addr = alloca <2 x double>, align 16 + %tmp = alloca <2 x double>, align 16 + store <2 x double> %a, ptr %a.addr, align 16 + store <2 x double> %b, ptr %b.addr, align 16 + store <2 x double> %c, ptr %c.addr, align 16 + %0 = load <2 x double>, ptr %a.addr, align 16 + %1 = load <2 x double>, ptr %c.addr, align 16 + %2 = load <2 x double>, ptr %b.addr, align 16 + %3 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %0, <2 x double> %1, <2 x double> %2) + store <2 x double> %3, ptr %tmp, align 16 + %4 = load <2 x double>, ptr %tmp, align 16 + %5 = load <2 x double>, ptr %c.addr, align 16 + %6 = load <2 x double>, ptr %b.addr, align 16 + %7 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %4, <2 x double> %5, <2 x double> %6) + ret <2 x double> %7 + } + + attributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) } + +... +--- +name: _Z12muladd_test1Dv2_dS_S_ +alignment: 16 +exposesReturnsTwice: false +legalized: false +regBankSelected: false +selected: false +failedISel: false +tracksRegLiveness: true +hasWinCFI: false +callsEHReturn: false +callsUnwindInit: false +hasEHCatchret: false +hasEHScopes: false +hasEHFunclets: false +isOutlined: false +debugInstrRef: true +failsVerification: false +tracksDebugUserValues: true +registers: [] +liveins: + - { reg: '$xmm0', virtual-reg: '' } + - { reg: '$xmm1', virtual-reg: '' } + - { reg: '$xmm2', virtual-reg: '' } +frameInfo: + isFrameAddressTaken: false + isReturnAddressTaken: false + hasStackMap: false + hasPatchPoint: false + stackSize: 0 + offsetAdjustment: 0 + maxAlignment: 16 + adjustsStack: false + hasCalls: false + stackProtector: '' + functionContext: '' + maxCallFrameSize: 0 + cvBytesOfCalleeSavedRegisters: 0 + hasOpaqueSPAdjustment: false + hasVAStart: false + hasMustTailInVarArgFunc: false + hasTailCall: false + localFrameSize: 0 + savePoint: '' + restorePoint: '' +fixedStack: [] +stack: + - { id: 0, name: a.addr, type: default, offset: -32, size: 16, alignment: 16, + stack-id: default, callee-saved-register: '', callee-saved-restored: true, + debug-info-variable: '', debug-info-expression: '', debug-info-location: '' } + - { id: 1, name: b.addr, type: default, offset: -48, size: 16, alignment: 16, + stack-id: default, callee-saved-register: '', callee-saved-restored: true, + debug-info-variable: '', debug-info-expression: '', debug-info-location: '' } + - { id: 2, name: c.addr, type: default, offset: -64, size: 16, alignment: 16, + stack-id: default, callee-saved-register: '', callee-saved-restored: true, + debug-info-variable: '', debug-info-expression: '', debug-info-location: '' } +entry_values: [] +callSites: [] +debugValueSubstitutions: [] +constants: [] +machineFunctionInfo: {} +body: | + bb.0.entry: + liveins: $xmm0, $xmm1, $xmm2 + + MOVAPDmr $rsp, 1, $noreg, -24, $noreg, renamable $xmm0 :: (store (s128) into %ir.a.addr) + MOVAPDmr $rsp, 1, $noreg, -40, $noreg, renamable $xmm1 :: (store (s128) into %ir.b.addr) + MOVAPDmr $rsp, 1, $noreg, -56, $noreg, renamable $xmm2 :: (store (s128) into %ir.c.addr) + renamable $xmm0 = nofpexcept MULPDrr killed renamable $xmm0, killed renamable $xmm1, implicit $mxcsr + renamable $xmm0 = nofpexcept ADDPDrr killed renamable $xmm0, killed renamable $xmm2, implicit $mxcsr + RET64 $xmm0 + +... +--- +name: _Z12muladd_test2Dv2_dS_S_ +alignment: 16 +exposesReturnsTwice: false +legalized: false +regBankSelected: false +selected: false +failedISel: false +tracksRegLiveness: true +hasWinCFI: false +callsEHReturn: false +callsUnwindInit: false +hasEHCatchret: false +hasEHScopes: false +hasEHFunclets: false +isOutlined: false +debugInstrRef: true +failsVerification: false +tracksDebugUserValues: true +registers: [] +liveins: + - { reg: '$xmm0', virtual-reg: '' } + - { reg: '$xmm1', virtual-reg: '' } + - { reg: '$xmm2', virtual-reg: '' } +frameInfo: + isFrameAddressTaken: false + isReturnAddressTaken: false + hasStackMap: false + hasPatchPoint: false + stackSize: 0 + offsetAdjustment: 0 + maxAlignment: 16 + adjustsStack: false + hasCalls: false + stackProtector: '' + functionContext: '' + maxCallFrameSize: 0 + cvBytesOfCalleeSavedRegisters: 0 + hasOpaqueSPAdjustment: false + hasVAStart: false + hasMustTailInVarArgFunc: false + hasTailCall: false + localFrameSize: 0 + savePoint: '' + restorePoint: '' +fixedStack: [] +stack: + - { id: 0, name: a.addr, type: default, offset: -32, size: 16, alignment: 16, + stack-id: default, callee-saved-register: '', callee-saved-restored: true, + debug-info-variable: '', debug-info-expression: '', debug-info-location: '' } + - { id: 1, name: b.addr, type: default, offset: -48, size: 16, alignment: 16, + stack-id: default, callee-saved-register: '', callee-saved-restored: true, + debug-info-variable: '', debug-info-expression: '', debug-info-location: '' } + - { id: 2, name: c.addr, type: default, offset: -64, size: 16, alignment: 16, + stack-id: default, callee-saved-register: '', callee-saved-restored: true, + debug-info-variable: '', debug-info-expression: '', debug-info-location: '' } + - { id: 3, name: tmp, type: default, offset: -80, size: 16, alignment: 16, + stack-id: default, callee-saved-register: '', callee-saved-restored: true, + debug-info-variable: '', debug-info-expression: '', debug-info-location: '' } +entry_values: [] +callSites: [] +debugValueSubstitutions: [] +constants: [] +machineFunctionInfo: {} +body: | + bb.0.entry: + liveins: $xmm0, $xmm1, $xmm2 + + MOVAPDmr $rsp, 1, $noreg, -24, $noreg, renamable $xmm0 :: (store (s128) into %ir.a.addr) + MOVAPDmr $rsp, 1, $noreg, -40, $noreg, renamable $xmm1 :: (store (s128) into %ir.b.addr) + MOVAPDmr $rsp, 1, $noreg, -56, $noreg, renamable $xmm2 :: (store (s128) into %ir.c.addr) + renamable $xmm0 = nofpexcept MULPDrr killed renamable $xmm0, killed renamable $xmm1, implicit $mxcsr + renamable $xmm0 = nofpexcept ADDPDrr killed renamable $xmm0, killed renamable $xmm2, implicit $mxcsr + MOVAPDmr $rsp, 1, $noreg, -72, $noreg, renamable $xmm0 :: (store (s128) into %ir.tmp) + RET64 $xmm0 + +... +--- +name: _Z12muladd_test3Dv2_dS_S_ +alignment: 16 +exposesReturnsTwice: false +legalized: false +regBankSelected: false +selected: false +failedISel: false +tracksRegLiveness: true +hasWinCFI: false +callsEHReturn: false +callsUnwindInit: false +hasEHCatchret: false +hasEHScopes: false +hasEHFunclets: false +isOutlined: false +debugInstrRef: true +failsVerification: false +tracksDebugUserValues: true +registers: [] +liveins: + - { reg: '$xmm0', virtual-reg: '' } + - { reg: '$xmm1', virtual-reg: '' } + - { reg: '$xmm2', virtual-reg: '' } +frameInfo: + isFrameAddressTaken: false + isReturnAddressTaken: false + hasStackMap: false + hasPatchPoint: false + stackSize: 0 + offsetAdjustment: 0 + maxAlignment: 16 + adjustsStack: false + hasCalls: false + stackProtector: '' + functionContext: '' + maxCallFrameSize: 0 + cvBytesOfCalleeSavedRegisters: 0 + hasOpaqueSPAdjustment: false + hasVAStart: false + hasMustTailInVarArgFunc: false + hasTailCall: false + localFrameSize: 0 + savePoint: '' + restorePoint: '' +fixedStack: [] +stack: + - { id: 0, name: a.addr, type: default, offset: -32, size: 16, alignment: 16, + stack-id: default, callee-saved-register: '', callee-saved-restored: true, + debug-info-variable: '', debug-info-expression: '', debug-info-location: '' } + - { id: 1, name: b.addr, type: default, offset: -48, size: 16, alignment: 16, + stack-id: default, callee-saved-register: '', callee-saved-restored: true, + debug-info-variable: '', debug-info-expression: '', debug-info-location: '' } + - { id: 2, name: c.addr, type: default, offset: -64, size: 16, alignment: 16, + stack-id: default, callee-saved-register: '', callee-saved-restored: true, + debug-info-variable: '', debug-info-expression: '', debug-info-location: '' } + - { id: 3, name: tmp, type: default, offset: -80, size: 16, alignment: 16, + stack-id: default, callee-saved-register: '', callee-saved-restored: true, + debug-info-variable: '', debug-info-expression: '', debug-info-location: '' } +entry_values: [] +callSites: [] +debugValueSubstitutions: [] +constants: [] +machineFunctionInfo: {} +body: | + bb.0.entry: + liveins: $xmm0, $xmm1, $xmm2 + + MOVAPDmr $rsp, 1, $noreg, -24, $noreg, renamable $xmm0 :: (store (s128) into %ir.a.addr) + MOVAPDmr $rsp, 1, $noreg, -40, $noreg, renamable $xmm1 :: (store (s128) into %ir.b.addr) + MOVAPDmr $rsp, 1, $noreg, -56, $noreg, renamable $xmm2 :: (store (s128) into %ir.c.addr) + renamable $xmm0 = nofpexcept MULPDrr killed renamable $xmm0, renamable $xmm2, implicit $mxcsr + renamable $xmm0 = nofpexcept ADDPDrr killed renamable $xmm0, renamable $xmm1, implicit $mxcsr + MOVAPDmr $rsp, 1, $noreg, -72, $noreg, renamable $xmm0 :: (store (s128) into %ir.tmp) + renamable $xmm0 = nofpexcept MULPDrr killed renamable $xmm0, killed renamable $xmm2, implicit $mxcsr + renamable $xmm0 = nofpexcept ADDPDrr killed renamable $xmm0, killed renamable $xmm1, implicit $mxcsr + RET64 $xmm0 + +... diff --git a/llvm/test/lab3/kuznetsov_artyom/test_out.mir b/llvm/test/lab3/kuznetsov_artyom/test_out.mir new file mode 100644 index 0000000000000..41af023693378 --- /dev/null +++ b/llvm/test/lab3/kuznetsov_artyom/test_out.mir @@ -0,0 +1,293 @@ +--- | + ; ModuleID = 'test.mir' + source_filename = "test.mir" + target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" + + define dso_local noundef <2 x double> @_Z12muladd_test1Dv2_dS_S_(<2 x double> noundef %a, <2 x double> noundef %b, <2 x double> noundef %c) { + entry: + %a.addr = alloca <2 x double>, align 16 + %b.addr = alloca <2 x double>, align 16 + %c.addr = alloca <2 x double>, align 16 + store <2 x double> %a, ptr %a.addr, align 16 + store <2 x double> %b, ptr %b.addr, align 16 + store <2 x double> %c, ptr %c.addr, align 16 + %0 = load <2 x double>, ptr %a.addr, align 16 + %1 = load <2 x double>, ptr %b.addr, align 16 + %2 = load <2 x double>, ptr %c.addr, align 16 + %3 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %0, <2 x double> %1, <2 x double> %2) + ret <2 x double> %3 + } + + ; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none) + declare <2 x double> @llvm.fmuladd.v2f64(<2 x double>, <2 x double>, <2 x double>) #0 + + define dso_local noundef <2 x double> @_Z12muladd_test2Dv2_dS_S_(<2 x double> noundef %a, <2 x double> noundef %b, <2 x double> noundef %c) { + entry: + %a.addr = alloca <2 x double>, align 16 + %b.addr = alloca <2 x double>, align 16 + %c.addr = alloca <2 x double>, align 16 + %tmp = alloca <2 x double>, align 16 + store <2 x double> %a, ptr %a.addr, align 16 + store <2 x double> %b, ptr %b.addr, align 16 + store <2 x double> %c, ptr %c.addr, align 16 + %0 = load <2 x double>, ptr %a.addr, align 16 + %1 = load <2 x double>, ptr %b.addr, align 16 + %mul = fmul <2 x double> %0, %1 + store <2 x double> %mul, ptr %tmp, align 16 + %2 = load <2 x double>, ptr %tmp, align 16 + %3 = load <2 x double>, ptr %c.addr, align 16 + %add = fadd <2 x double> %2, %3 + store <2 x double> %add, ptr %tmp, align 16 + %4 = load <2 x double>, ptr %tmp, align 16 + ret <2 x double> %4 + } + + define dso_local noundef <2 x double> @_Z12muladd_test3Dv2_dS_S_(<2 x double> noundef %a, <2 x double> noundef %b, <2 x double> noundef %c) { + entry: + %a.addr = alloca <2 x double>, align 16 + %b.addr = alloca <2 x double>, align 16 + %c.addr = alloca <2 x double>, align 16 + %tmp = alloca <2 x double>, align 16 + store <2 x double> %a, ptr %a.addr, align 16 + store <2 x double> %b, ptr %b.addr, align 16 + store <2 x double> %c, ptr %c.addr, align 16 + %0 = load <2 x double>, ptr %a.addr, align 16 + %1 = load <2 x double>, ptr %c.addr, align 16 + %2 = load <2 x double>, ptr %b.addr, align 16 + %3 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %0, <2 x double> %1, <2 x double> %2) + store <2 x double> %3, ptr %tmp, align 16 + %4 = load <2 x double>, ptr %tmp, align 16 + %5 = load <2 x double>, ptr %c.addr, align 16 + %6 = load <2 x double>, ptr %b.addr, align 16 + %7 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %4, <2 x double> %5, <2 x double> %6) + ret <2 x double> %7 + } + + attributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) } + +... +--- +name: _Z12muladd_test1Dv2_dS_S_ +alignment: 16 +exposesReturnsTwice: false +legalized: false +regBankSelected: false +selected: false +failedISel: false +tracksRegLiveness: true +hasWinCFI: false +callsEHReturn: false +callsUnwindInit: false +hasEHCatchret: false +hasEHScopes: false +hasEHFunclets: false +isOutlined: false +debugInstrRef: true +failsVerification: false +tracksDebugUserValues: true +registers: [] +liveins: + - { reg: '$xmm0', virtual-reg: '' } + - { reg: '$xmm1', virtual-reg: '' } + - { reg: '$xmm2', virtual-reg: '' } +frameInfo: + isFrameAddressTaken: false + isReturnAddressTaken: false + hasStackMap: false + hasPatchPoint: false + stackSize: 0 + offsetAdjustment: 0 + maxAlignment: 16 + adjustsStack: false + hasCalls: false + stackProtector: '' + functionContext: '' + maxCallFrameSize: 0 + cvBytesOfCalleeSavedRegisters: 0 + hasOpaqueSPAdjustment: false + hasVAStart: false + hasMustTailInVarArgFunc: false + hasTailCall: false + localFrameSize: 0 + savePoint: '' + restorePoint: '' +fixedStack: [] +stack: + - { id: 0, name: a.addr, type: default, offset: -32, size: 16, alignment: 16, + stack-id: default, callee-saved-register: '', callee-saved-restored: true, + debug-info-variable: '', debug-info-expression: '', debug-info-location: '' } + - { id: 1, name: b.addr, type: default, offset: -48, size: 16, alignment: 16, + stack-id: default, callee-saved-register: '', callee-saved-restored: true, + debug-info-variable: '', debug-info-expression: '', debug-info-location: '' } + - { id: 2, name: c.addr, type: default, offset: -64, size: 16, alignment: 16, + stack-id: default, callee-saved-register: '', callee-saved-restored: true, + debug-info-variable: '', debug-info-expression: '', debug-info-location: '' } +entry_values: [] +callSites: [] +debugValueSubstitutions: [] +constants: [] +machineFunctionInfo: {} +body: | + bb.0.entry: + liveins: $xmm0, $xmm1, $xmm2 + + MOVAPDmr $rsp, 1, $noreg, -24, $noreg, renamable $xmm0 :: (store (s128) into %ir.a.addr) + MOVAPDmr $rsp, 1, $noreg, -40, $noreg, renamable $xmm1 :: (store (s128) into %ir.b.addr) + MOVAPDmr $rsp, 1, $noreg, -56, $noreg, renamable $xmm2 :: (store (s128) into %ir.c.addr) + $xmm0 = VFMADD213PDZ128r $xmm0, $xmm1, $xmm2, implicit $mxcsr + RET64 $xmm0 + +... +--- +name: _Z12muladd_test2Dv2_dS_S_ +alignment: 16 +exposesReturnsTwice: false +legalized: false +regBankSelected: false +selected: false +failedISel: false +tracksRegLiveness: true +hasWinCFI: false +callsEHReturn: false +callsUnwindInit: false +hasEHCatchret: false +hasEHScopes: false +hasEHFunclets: false +isOutlined: false +debugInstrRef: true +failsVerification: false +tracksDebugUserValues: true +registers: [] +liveins: + - { reg: '$xmm0', virtual-reg: '' } + - { reg: '$xmm1', virtual-reg: '' } + - { reg: '$xmm2', virtual-reg: '' } +frameInfo: + isFrameAddressTaken: false + isReturnAddressTaken: false + hasStackMap: false + hasPatchPoint: false + stackSize: 0 + offsetAdjustment: 0 + maxAlignment: 16 + adjustsStack: false + hasCalls: false + stackProtector: '' + functionContext: '' + maxCallFrameSize: 0 + cvBytesOfCalleeSavedRegisters: 0 + hasOpaqueSPAdjustment: false + hasVAStart: false + hasMustTailInVarArgFunc: false + hasTailCall: false + localFrameSize: 0 + savePoint: '' + restorePoint: '' +fixedStack: [] +stack: + - { id: 0, name: a.addr, type: default, offset: -32, size: 16, alignment: 16, + stack-id: default, callee-saved-register: '', callee-saved-restored: true, + debug-info-variable: '', debug-info-expression: '', debug-info-location: '' } + - { id: 1, name: b.addr, type: default, offset: -48, size: 16, alignment: 16, + stack-id: default, callee-saved-register: '', callee-saved-restored: true, + debug-info-variable: '', debug-info-expression: '', debug-info-location: '' } + - { id: 2, name: c.addr, type: default, offset: -64, size: 16, alignment: 16, + stack-id: default, callee-saved-register: '', callee-saved-restored: true, + debug-info-variable: '', debug-info-expression: '', debug-info-location: '' } + - { id: 3, name: tmp, type: default, offset: -80, size: 16, alignment: 16, + stack-id: default, callee-saved-register: '', callee-saved-restored: true, + debug-info-variable: '', debug-info-expression: '', debug-info-location: '' } +entry_values: [] +callSites: [] +debugValueSubstitutions: [] +constants: [] +machineFunctionInfo: {} +body: | + bb.0.entry: + liveins: $xmm0, $xmm1, $xmm2 + + MOVAPDmr $rsp, 1, $noreg, -24, $noreg, renamable $xmm0 :: (store (s128) into %ir.a.addr) + MOVAPDmr $rsp, 1, $noreg, -40, $noreg, renamable $xmm1 :: (store (s128) into %ir.b.addr) + MOVAPDmr $rsp, 1, $noreg, -56, $noreg, renamable $xmm2 :: (store (s128) into %ir.c.addr) + $xmm0 = VFMADD213PDZ128r $xmm0, $xmm1, $xmm2, implicit $mxcsr + MOVAPDmr $rsp, 1, $noreg, -72, $noreg, renamable $xmm0 :: (store (s128) into %ir.tmp) + RET64 $xmm0 + +... +--- +name: _Z12muladd_test3Dv2_dS_S_ +alignment: 16 +exposesReturnsTwice: false +legalized: false +regBankSelected: false +selected: false +failedISel: false +tracksRegLiveness: true +hasWinCFI: false +callsEHReturn: false +callsUnwindInit: false +hasEHCatchret: false +hasEHScopes: false +hasEHFunclets: false +isOutlined: false +debugInstrRef: true +failsVerification: false +tracksDebugUserValues: true +registers: [] +liveins: + - { reg: '$xmm0', virtual-reg: '' } + - { reg: '$xmm1', virtual-reg: '' } + - { reg: '$xmm2', virtual-reg: '' } +frameInfo: + isFrameAddressTaken: false + isReturnAddressTaken: false + hasStackMap: false + hasPatchPoint: false + stackSize: 0 + offsetAdjustment: 0 + maxAlignment: 16 + adjustsStack: false + hasCalls: false + stackProtector: '' + functionContext: '' + maxCallFrameSize: 0 + cvBytesOfCalleeSavedRegisters: 0 + hasOpaqueSPAdjustment: false + hasVAStart: false + hasMustTailInVarArgFunc: false + hasTailCall: false + localFrameSize: 0 + savePoint: '' + restorePoint: '' +fixedStack: [] +stack: + - { id: 0, name: a.addr, type: default, offset: -32, size: 16, alignment: 16, + stack-id: default, callee-saved-register: '', callee-saved-restored: true, + debug-info-variable: '', debug-info-expression: '', debug-info-location: '' } + - { id: 1, name: b.addr, type: default, offset: -48, size: 16, alignment: 16, + stack-id: default, callee-saved-register: '', callee-saved-restored: true, + debug-info-variable: '', debug-info-expression: '', debug-info-location: '' } + - { id: 2, name: c.addr, type: default, offset: -64, size: 16, alignment: 16, + stack-id: default, callee-saved-register: '', callee-saved-restored: true, + debug-info-variable: '', debug-info-expression: '', debug-info-location: '' } + - { id: 3, name: tmp, type: default, offset: -80, size: 16, alignment: 16, + stack-id: default, callee-saved-register: '', callee-saved-restored: true, + debug-info-variable: '', debug-info-expression: '', debug-info-location: '' } +entry_values: [] +callSites: [] +debugValueSubstitutions: [] +constants: [] +machineFunctionInfo: {} +body: | + bb.0.entry: + liveins: $xmm0, $xmm1, $xmm2 + + MOVAPDmr $rsp, 1, $noreg, -24, $noreg, renamable $xmm0 :: (store (s128) into %ir.a.addr) + MOVAPDmr $rsp, 1, $noreg, -40, $noreg, renamable $xmm1 :: (store (s128) into %ir.b.addr) + MOVAPDmr $rsp, 1, $noreg, -56, $noreg, renamable $xmm2 :: (store (s128) into %ir.c.addr) + $xmm0 = VFMADD213PDZ128r $xmm0, $xmm2, $xmm1, implicit $mxcsr + MOVAPDmr $rsp, 1, $noreg, -72, $noreg, renamable $xmm0 :: (store (s128) into %ir.tmp) + $xmm0 = VFMADD213PDZ128r $xmm0, $xmm2, $xmm1, implicit $mxcsr + RET64 $xmm0 + +... From 231bed8133ebf343bc6fe8a1e5adaa3c67a7a968 Mon Sep 17 00:00:00 2001 From: Kuznetsov-Artyom Date: Sun, 21 Apr 2024 00:10:01 +0300 Subject: [PATCH 02/10] change tests --- llvm/test/lab3/kuznetsov_artyom/test.ll | 58 ---- llvm/test/lab3/kuznetsov_artyom/test.mir | 300 ------------------- llvm/test/lab3/kuznetsov_artyom/test_ll.ll | 43 +++ llvm/test/lab3/kuznetsov_artyom/test_out.mir | 136 +++------ llvm/test/lab3/kuznetsov_artyom/testing.mir | 246 +++++++++++++++ 5 files changed, 324 insertions(+), 459 deletions(-) delete mode 100644 llvm/test/lab3/kuznetsov_artyom/test.ll delete mode 100644 llvm/test/lab3/kuznetsov_artyom/test.mir create mode 100644 llvm/test/lab3/kuznetsov_artyom/test_ll.ll create mode 100644 llvm/test/lab3/kuznetsov_artyom/testing.mir diff --git a/llvm/test/lab3/kuznetsov_artyom/test.ll b/llvm/test/lab3/kuznetsov_artyom/test.ll deleted file mode 100644 index 0eed142455a54..0000000000000 --- a/llvm/test/lab3/kuznetsov_artyom/test.ll +++ /dev/null @@ -1,58 +0,0 @@ -define dso_local noundef <2 x double> @_Z12muladd_test1Dv2_dS_S_(<2 x double> noundef %a, <2 x double> noundef %b, <2 x double> noundef %c) { -entry: - %a.addr = alloca <2 x double>, align 16 - %b.addr = alloca <2 x double>, align 16 - %c.addr = alloca <2 x double>, align 16 - store <2 x double> %a, ptr %a.addr, align 16 - store <2 x double> %b, ptr %b.addr, align 16 - store <2 x double> %c, ptr %c.addr, align 16 - %0 = load <2 x double>, ptr %a.addr, align 16 - %1 = load <2 x double>, ptr %b.addr, align 16 - %2 = load <2 x double>, ptr %c.addr, align 16 - %3 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %0, <2 x double> %1, <2 x double> %2) - ret <2 x double> %3 -} - -declare <2 x double> @llvm.fmuladd.v2f64(<2 x double>, <2 x double>, <2 x double>) - -define dso_local noundef <2 x double> @_Z12muladd_test2Dv2_dS_S_(<2 x double> noundef %a, <2 x double> noundef %b, <2 x double> noundef %c) { -entry: - %a.addr = alloca <2 x double>, align 16 - %b.addr = alloca <2 x double>, align 16 - %c.addr = alloca <2 x double>, align 16 - %tmp = alloca <2 x double>, align 16 - store <2 x double> %a, ptr %a.addr, align 16 - store <2 x double> %b, ptr %b.addr, align 16 - store <2 x double> %c, ptr %c.addr, align 16 - %0 = load <2 x double>, ptr %a.addr, align 16 - %1 = load <2 x double>, ptr %b.addr, align 16 - %mul = fmul <2 x double> %0, %1 - store <2 x double> %mul, ptr %tmp, align 16 - %2 = load <2 x double>, ptr %tmp, align 16 - %3 = load <2 x double>, ptr %c.addr, align 16 - %add = fadd <2 x double> %2, %3 - store <2 x double> %add, ptr %tmp, align 16 - %4 = load <2 x double>, ptr %tmp, align 16 - ret <2 x double> %4 -} - -define dso_local noundef <2 x double> @_Z12muladd_test3Dv2_dS_S_(<2 x double> noundef %a, <2 x double> noundef %b, <2 x double> noundef %c) { -entry: - %a.addr = alloca <2 x double>, align 16 - %b.addr = alloca <2 x double>, align 16 - %c.addr = alloca <2 x double>, align 16 - %tmp = alloca <2 x double>, align 16 - store <2 x double> %a, ptr %a.addr, align 16 - store <2 x double> %b, ptr %b.addr, align 16 - store <2 x double> %c, ptr %c.addr, align 16 - %0 = load <2 x double>, ptr %a.addr, align 16 - %1 = load <2 x double>, ptr %c.addr, align 16 - %2 = load <2 x double>, ptr %b.addr, align 16 - %3 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %0, <2 x double> %1, <2 x double> %2) - store <2 x double> %3, ptr %tmp, align 16 - %4 = load <2 x double>, ptr %tmp, align 16 - %5 = load <2 x double>, ptr %c.addr, align 16 - %6 = load <2 x double>, ptr %b.addr, align 16 - %7 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %4, <2 x double> %5, <2 x double> %6) - ret <2 x double> %7 -} \ No newline at end of file diff --git a/llvm/test/lab3/kuznetsov_artyom/test.mir b/llvm/test/lab3/kuznetsov_artyom/test.mir deleted file mode 100644 index 821e878b6cb46..0000000000000 --- a/llvm/test/lab3/kuznetsov_artyom/test.mir +++ /dev/null @@ -1,300 +0,0 @@ -# RUN: llc -march=x86-64 test.mir -run-pass=x86-muladd %s -o - | FileCheck %s - - ---- | - ; ModuleID = 'test.ll' - source_filename = "test.ll" - target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" - - define dso_local noundef <2 x double> @_Z12muladd_test1Dv2_dS_S_(<2 x double> noundef %a, <2 x double> noundef %b, <2 x double> noundef %c) { - entry: - %a.addr = alloca <2 x double>, align 16 - %b.addr = alloca <2 x double>, align 16 - %c.addr = alloca <2 x double>, align 16 - store <2 x double> %a, ptr %a.addr, align 16 - store <2 x double> %b, ptr %b.addr, align 16 - store <2 x double> %c, ptr %c.addr, align 16 - %0 = load <2 x double>, ptr %a.addr, align 16 - %1 = load <2 x double>, ptr %b.addr, align 16 - %2 = load <2 x double>, ptr %c.addr, align 16 - %3 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %0, <2 x double> %1, <2 x double> %2) - ret <2 x double> %3 - } - - ; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none) - declare <2 x double> @llvm.fmuladd.v2f64(<2 x double>, <2 x double>, <2 x double>) #0 - - define dso_local noundef <2 x double> @_Z12muladd_test2Dv2_dS_S_(<2 x double> noundef %a, <2 x double> noundef %b, <2 x double> noundef %c) { - entry: - %a.addr = alloca <2 x double>, align 16 - %b.addr = alloca <2 x double>, align 16 - %c.addr = alloca <2 x double>, align 16 - %tmp = alloca <2 x double>, align 16 - store <2 x double> %a, ptr %a.addr, align 16 - store <2 x double> %b, ptr %b.addr, align 16 - store <2 x double> %c, ptr %c.addr, align 16 - %0 = load <2 x double>, ptr %a.addr, align 16 - %1 = load <2 x double>, ptr %b.addr, align 16 - %mul = fmul <2 x double> %0, %1 - store <2 x double> %mul, ptr %tmp, align 16 - %2 = load <2 x double>, ptr %tmp, align 16 - %3 = load <2 x double>, ptr %c.addr, align 16 - %add = fadd <2 x double> %2, %3 - store <2 x double> %add, ptr %tmp, align 16 - %4 = load <2 x double>, ptr %tmp, align 16 - ret <2 x double> %4 - } - - define dso_local noundef <2 x double> @_Z12muladd_test3Dv2_dS_S_(<2 x double> noundef %a, <2 x double> noundef %b, <2 x double> noundef %c) { - entry: - %a.addr = alloca <2 x double>, align 16 - %b.addr = alloca <2 x double>, align 16 - %c.addr = alloca <2 x double>, align 16 - %tmp = alloca <2 x double>, align 16 - store <2 x double> %a, ptr %a.addr, align 16 - store <2 x double> %b, ptr %b.addr, align 16 - store <2 x double> %c, ptr %c.addr, align 16 - %0 = load <2 x double>, ptr %a.addr, align 16 - %1 = load <2 x double>, ptr %c.addr, align 16 - %2 = load <2 x double>, ptr %b.addr, align 16 - %3 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %0, <2 x double> %1, <2 x double> %2) - store <2 x double> %3, ptr %tmp, align 16 - %4 = load <2 x double>, ptr %tmp, align 16 - %5 = load <2 x double>, ptr %c.addr, align 16 - %6 = load <2 x double>, ptr %b.addr, align 16 - %7 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %4, <2 x double> %5, <2 x double> %6) - ret <2 x double> %7 - } - - attributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) } - -... ---- -name: _Z12muladd_test1Dv2_dS_S_ -alignment: 16 -exposesReturnsTwice: false -legalized: false -regBankSelected: false -selected: false -failedISel: false -tracksRegLiveness: true -hasWinCFI: false -callsEHReturn: false -callsUnwindInit: false -hasEHCatchret: false -hasEHScopes: false -hasEHFunclets: false -isOutlined: false -debugInstrRef: true -failsVerification: false -tracksDebugUserValues: true -registers: [] -liveins: - - { reg: '$xmm0', virtual-reg: '' } - - { reg: '$xmm1', virtual-reg: '' } - - { reg: '$xmm2', virtual-reg: '' } -frameInfo: - isFrameAddressTaken: false - isReturnAddressTaken: false - hasStackMap: false - hasPatchPoint: false - stackSize: 0 - offsetAdjustment: 0 - maxAlignment: 16 - adjustsStack: false - hasCalls: false - stackProtector: '' - functionContext: '' - maxCallFrameSize: 0 - cvBytesOfCalleeSavedRegisters: 0 - hasOpaqueSPAdjustment: false - hasVAStart: false - hasMustTailInVarArgFunc: false - hasTailCall: false - localFrameSize: 0 - savePoint: '' - restorePoint: '' -fixedStack: [] -stack: - - { id: 0, name: a.addr, type: default, offset: -32, size: 16, alignment: 16, - stack-id: default, callee-saved-register: '', callee-saved-restored: true, - debug-info-variable: '', debug-info-expression: '', debug-info-location: '' } - - { id: 1, name: b.addr, type: default, offset: -48, size: 16, alignment: 16, - stack-id: default, callee-saved-register: '', callee-saved-restored: true, - debug-info-variable: '', debug-info-expression: '', debug-info-location: '' } - - { id: 2, name: c.addr, type: default, offset: -64, size: 16, alignment: 16, - stack-id: default, callee-saved-register: '', callee-saved-restored: true, - debug-info-variable: '', debug-info-expression: '', debug-info-location: '' } -entry_values: [] -callSites: [] -debugValueSubstitutions: [] -constants: [] -machineFunctionInfo: {} -body: | - bb.0.entry: - liveins: $xmm0, $xmm1, $xmm2 - - MOVAPDmr $rsp, 1, $noreg, -24, $noreg, renamable $xmm0 :: (store (s128) into %ir.a.addr) - MOVAPDmr $rsp, 1, $noreg, -40, $noreg, renamable $xmm1 :: (store (s128) into %ir.b.addr) - MOVAPDmr $rsp, 1, $noreg, -56, $noreg, renamable $xmm2 :: (store (s128) into %ir.c.addr) - renamable $xmm0 = nofpexcept MULPDrr killed renamable $xmm0, killed renamable $xmm1, implicit $mxcsr - renamable $xmm0 = nofpexcept ADDPDrr killed renamable $xmm0, killed renamable $xmm2, implicit $mxcsr - RET64 $xmm0 - -... ---- -name: _Z12muladd_test2Dv2_dS_S_ -alignment: 16 -exposesReturnsTwice: false -legalized: false -regBankSelected: false -selected: false -failedISel: false -tracksRegLiveness: true -hasWinCFI: false -callsEHReturn: false -callsUnwindInit: false -hasEHCatchret: false -hasEHScopes: false -hasEHFunclets: false -isOutlined: false -debugInstrRef: true -failsVerification: false -tracksDebugUserValues: true -registers: [] -liveins: - - { reg: '$xmm0', virtual-reg: '' } - - { reg: '$xmm1', virtual-reg: '' } - - { reg: '$xmm2', virtual-reg: '' } -frameInfo: - isFrameAddressTaken: false - isReturnAddressTaken: false - hasStackMap: false - hasPatchPoint: false - stackSize: 0 - offsetAdjustment: 0 - maxAlignment: 16 - adjustsStack: false - hasCalls: false - stackProtector: '' - functionContext: '' - maxCallFrameSize: 0 - cvBytesOfCalleeSavedRegisters: 0 - hasOpaqueSPAdjustment: false - hasVAStart: false - hasMustTailInVarArgFunc: false - hasTailCall: false - localFrameSize: 0 - savePoint: '' - restorePoint: '' -fixedStack: [] -stack: - - { id: 0, name: a.addr, type: default, offset: -32, size: 16, alignment: 16, - stack-id: default, callee-saved-register: '', callee-saved-restored: true, - debug-info-variable: '', debug-info-expression: '', debug-info-location: '' } - - { id: 1, name: b.addr, type: default, offset: -48, size: 16, alignment: 16, - stack-id: default, callee-saved-register: '', callee-saved-restored: true, - debug-info-variable: '', debug-info-expression: '', debug-info-location: '' } - - { id: 2, name: c.addr, type: default, offset: -64, size: 16, alignment: 16, - stack-id: default, callee-saved-register: '', callee-saved-restored: true, - debug-info-variable: '', debug-info-expression: '', debug-info-location: '' } - - { id: 3, name: tmp, type: default, offset: -80, size: 16, alignment: 16, - stack-id: default, callee-saved-register: '', callee-saved-restored: true, - debug-info-variable: '', debug-info-expression: '', debug-info-location: '' } -entry_values: [] -callSites: [] -debugValueSubstitutions: [] -constants: [] -machineFunctionInfo: {} -body: | - bb.0.entry: - liveins: $xmm0, $xmm1, $xmm2 - - MOVAPDmr $rsp, 1, $noreg, -24, $noreg, renamable $xmm0 :: (store (s128) into %ir.a.addr) - MOVAPDmr $rsp, 1, $noreg, -40, $noreg, renamable $xmm1 :: (store (s128) into %ir.b.addr) - MOVAPDmr $rsp, 1, $noreg, -56, $noreg, renamable $xmm2 :: (store (s128) into %ir.c.addr) - renamable $xmm0 = nofpexcept MULPDrr killed renamable $xmm0, killed renamable $xmm1, implicit $mxcsr - renamable $xmm0 = nofpexcept ADDPDrr killed renamable $xmm0, killed renamable $xmm2, implicit $mxcsr - MOVAPDmr $rsp, 1, $noreg, -72, $noreg, renamable $xmm0 :: (store (s128) into %ir.tmp) - RET64 $xmm0 - -... ---- -name: _Z12muladd_test3Dv2_dS_S_ -alignment: 16 -exposesReturnsTwice: false -legalized: false -regBankSelected: false -selected: false -failedISel: false -tracksRegLiveness: true -hasWinCFI: false -callsEHReturn: false -callsUnwindInit: false -hasEHCatchret: false -hasEHScopes: false -hasEHFunclets: false -isOutlined: false -debugInstrRef: true -failsVerification: false -tracksDebugUserValues: true -registers: [] -liveins: - - { reg: '$xmm0', virtual-reg: '' } - - { reg: '$xmm1', virtual-reg: '' } - - { reg: '$xmm2', virtual-reg: '' } -frameInfo: - isFrameAddressTaken: false - isReturnAddressTaken: false - hasStackMap: false - hasPatchPoint: false - stackSize: 0 - offsetAdjustment: 0 - maxAlignment: 16 - adjustsStack: false - hasCalls: false - stackProtector: '' - functionContext: '' - maxCallFrameSize: 0 - cvBytesOfCalleeSavedRegisters: 0 - hasOpaqueSPAdjustment: false - hasVAStart: false - hasMustTailInVarArgFunc: false - hasTailCall: false - localFrameSize: 0 - savePoint: '' - restorePoint: '' -fixedStack: [] -stack: - - { id: 0, name: a.addr, type: default, offset: -32, size: 16, alignment: 16, - stack-id: default, callee-saved-register: '', callee-saved-restored: true, - debug-info-variable: '', debug-info-expression: '', debug-info-location: '' } - - { id: 1, name: b.addr, type: default, offset: -48, size: 16, alignment: 16, - stack-id: default, callee-saved-register: '', callee-saved-restored: true, - debug-info-variable: '', debug-info-expression: '', debug-info-location: '' } - - { id: 2, name: c.addr, type: default, offset: -64, size: 16, alignment: 16, - stack-id: default, callee-saved-register: '', callee-saved-restored: true, - debug-info-variable: '', debug-info-expression: '', debug-info-location: '' } - - { id: 3, name: tmp, type: default, offset: -80, size: 16, alignment: 16, - stack-id: default, callee-saved-register: '', callee-saved-restored: true, - debug-info-variable: '', debug-info-expression: '', debug-info-location: '' } -entry_values: [] -callSites: [] -debugValueSubstitutions: [] -constants: [] -machineFunctionInfo: {} -body: | - bb.0.entry: - liveins: $xmm0, $xmm1, $xmm2 - - MOVAPDmr $rsp, 1, $noreg, -24, $noreg, renamable $xmm0 :: (store (s128) into %ir.a.addr) - MOVAPDmr $rsp, 1, $noreg, -40, $noreg, renamable $xmm1 :: (store (s128) into %ir.b.addr) - MOVAPDmr $rsp, 1, $noreg, -56, $noreg, renamable $xmm2 :: (store (s128) into %ir.c.addr) - renamable $xmm0 = nofpexcept MULPDrr killed renamable $xmm0, renamable $xmm2, implicit $mxcsr - renamable $xmm0 = nofpexcept ADDPDrr killed renamable $xmm0, renamable $xmm1, implicit $mxcsr - MOVAPDmr $rsp, 1, $noreg, -72, $noreg, renamable $xmm0 :: (store (s128) into %ir.tmp) - renamable $xmm0 = nofpexcept MULPDrr killed renamable $xmm0, killed renamable $xmm2, implicit $mxcsr - renamable $xmm0 = nofpexcept ADDPDrr killed renamable $xmm0, killed renamable $xmm1, implicit $mxcsr - RET64 $xmm0 - -... diff --git a/llvm/test/lab3/kuznetsov_artyom/test_ll.ll b/llvm/test/lab3/kuznetsov_artyom/test_ll.ll new file mode 100644 index 0000000000000..01e65938a0fa3 --- /dev/null +++ b/llvm/test/lab3/kuznetsov_artyom/test_ll.ll @@ -0,0 +1,43 @@ +; ModuleID = 'test.cpp' +source_filename = "test.cpp" +target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" +target triple = "x86_64-unknown-linux-gnu" + +; Function Attrs: mustprogress nofree nosync nounwind willreturn memory(none) uwtable +define dso_local noundef <2 x double> @_Z12muladd_test1Dv2_dS_S_(<2 x double> noundef %a, <2 x double> noundef %b, <2 x double> noundef %c) local_unnamed_addr #0 { +entry: + %0 = tail call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %a, <2 x double> %b, <2 x double> %c) + ret <2 x double> %0 +} + +; Function Attrs: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) +declare <2 x double> @llvm.fmuladd.v2f64(<2 x double>, <2 x double>, <2 x double>) #1 + +; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(none) uwtable +define dso_local noundef <2 x double> @_Z12muladd_test2Dv2_dS_S_(<2 x double> noundef %a, <2 x double> noundef %b, <2 x double> noundef %c) local_unnamed_addr #2 { +entry: + %mul = fmul <2 x double> %a, %b + %add = fadd <2 x double> %mul, %c + ret <2 x double> %add +} + +; Function Attrs: mustprogress nofree nosync nounwind willreturn memory(none) uwtable +define dso_local noundef <2 x double> @_Z12muladd_test3Dv2_dS_S_(<2 x double> noundef %a, <2 x double> noundef %b, <2 x double> noundef %c) local_unnamed_addr #0 { +entry: + %0 = tail call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %a, <2 x double> %c, <2 x double> %b) + %1 = tail call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %0, <2 x double> %c, <2 x double> %b) + ret <2 x double> %1 +} + +attributes #0 = { mustprogress nofree nosync nounwind willreturn memory(none) uwtable "min-legal-vector-width"="128" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" } +attributes #1 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) } +attributes #2 = { mustprogress nofree norecurse nosync nounwind willreturn memory(none) uwtable "min-legal-vector-width"="128" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" } + +!llvm.module.flags = !{!0, !1, !2, !3} +!llvm.ident = !{!4} + +!0 = !{i32 1, !"wchar_size", i32 4} +!1 = !{i32 8, !"PIC Level", i32 2} +!2 = !{i32 7, !"PIE Level", i32 2} +!3 = !{i32 7, !"uwtable", i32 2} +!4 = !{!"clang version 17.0.6 (https://github.com/Kuznetsov-Artyom/llvm-nnsu-2024 a7816066a7b000bd8961dacdc49fc4d7b6c649f0)"} diff --git a/llvm/test/lab3/kuznetsov_artyom/test_out.mir b/llvm/test/lab3/kuznetsov_artyom/test_out.mir index 41af023693378..e83a35e36dbb9 100644 --- a/llvm/test/lab3/kuznetsov_artyom/test_out.mir +++ b/llvm/test/lab3/kuznetsov_artyom/test_out.mir @@ -1,69 +1,47 @@ --- | ; ModuleID = 'test.mir' - source_filename = "test.mir" + source_filename = "test.cpp" target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" + target triple = "x86_64-unknown-linux-gnu" - define dso_local noundef <2 x double> @_Z12muladd_test1Dv2_dS_S_(<2 x double> noundef %a, <2 x double> noundef %b, <2 x double> noundef %c) { + ; Function Attrs: mustprogress nofree nosync nounwind willreturn memory(none) uwtable + define dso_local noundef <2 x double> @_Z12muladd_test1Dv2_dS_S_(<2 x double> noundef %a, <2 x double> noundef %b, <2 x double> noundef %c) local_unnamed_addr #0 { entry: - %a.addr = alloca <2 x double>, align 16 - %b.addr = alloca <2 x double>, align 16 - %c.addr = alloca <2 x double>, align 16 - store <2 x double> %a, ptr %a.addr, align 16 - store <2 x double> %b, ptr %b.addr, align 16 - store <2 x double> %c, ptr %c.addr, align 16 - %0 = load <2 x double>, ptr %a.addr, align 16 - %1 = load <2 x double>, ptr %b.addr, align 16 - %2 = load <2 x double>, ptr %c.addr, align 16 - %3 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %0, <2 x double> %1, <2 x double> %2) - ret <2 x double> %3 + %0 = tail call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %a, <2 x double> %b, <2 x double> %c) + ret <2 x double> %0 } ; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none) - declare <2 x double> @llvm.fmuladd.v2f64(<2 x double>, <2 x double>, <2 x double>) #0 + declare <2 x double> @llvm.fmuladd.v2f64(<2 x double>, <2 x double>, <2 x double>) #1 - define dso_local noundef <2 x double> @_Z12muladd_test2Dv2_dS_S_(<2 x double> noundef %a, <2 x double> noundef %b, <2 x double> noundef %c) { + ; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(none) uwtable + define dso_local noundef <2 x double> @_Z12muladd_test2Dv2_dS_S_(<2 x double> noundef %a, <2 x double> noundef %b, <2 x double> noundef %c) local_unnamed_addr #2 { entry: - %a.addr = alloca <2 x double>, align 16 - %b.addr = alloca <2 x double>, align 16 - %c.addr = alloca <2 x double>, align 16 - %tmp = alloca <2 x double>, align 16 - store <2 x double> %a, ptr %a.addr, align 16 - store <2 x double> %b, ptr %b.addr, align 16 - store <2 x double> %c, ptr %c.addr, align 16 - %0 = load <2 x double>, ptr %a.addr, align 16 - %1 = load <2 x double>, ptr %b.addr, align 16 - %mul = fmul <2 x double> %0, %1 - store <2 x double> %mul, ptr %tmp, align 16 - %2 = load <2 x double>, ptr %tmp, align 16 - %3 = load <2 x double>, ptr %c.addr, align 16 - %add = fadd <2 x double> %2, %3 - store <2 x double> %add, ptr %tmp, align 16 - %4 = load <2 x double>, ptr %tmp, align 16 - ret <2 x double> %4 + %mul = fmul <2 x double> %a, %b + %add = fadd <2 x double> %mul, %c + ret <2 x double> %add } - define dso_local noundef <2 x double> @_Z12muladd_test3Dv2_dS_S_(<2 x double> noundef %a, <2 x double> noundef %b, <2 x double> noundef %c) { + ; Function Attrs: mustprogress nofree nosync nounwind willreturn memory(none) uwtable + define dso_local noundef <2 x double> @_Z12muladd_test3Dv2_dS_S_(<2 x double> noundef %a, <2 x double> noundef %b, <2 x double> noundef %c) local_unnamed_addr #0 { entry: - %a.addr = alloca <2 x double>, align 16 - %b.addr = alloca <2 x double>, align 16 - %c.addr = alloca <2 x double>, align 16 - %tmp = alloca <2 x double>, align 16 - store <2 x double> %a, ptr %a.addr, align 16 - store <2 x double> %b, ptr %b.addr, align 16 - store <2 x double> %c, ptr %c.addr, align 16 - %0 = load <2 x double>, ptr %a.addr, align 16 - %1 = load <2 x double>, ptr %c.addr, align 16 - %2 = load <2 x double>, ptr %b.addr, align 16 - %3 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %0, <2 x double> %1, <2 x double> %2) - store <2 x double> %3, ptr %tmp, align 16 - %4 = load <2 x double>, ptr %tmp, align 16 - %5 = load <2 x double>, ptr %c.addr, align 16 - %6 = load <2 x double>, ptr %b.addr, align 16 - %7 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %4, <2 x double> %5, <2 x double> %6) - ret <2 x double> %7 + %0 = tail call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %a, <2 x double> %c, <2 x double> %b) + %1 = tail call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %0, <2 x double> %c, <2 x double> %b) + ret <2 x double> %1 } - attributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) } + attributes #0 = { mustprogress nofree nosync nounwind willreturn memory(none) uwtable "min-legal-vector-width"="128" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" } + attributes #1 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) } + attributes #2 = { mustprogress nofree norecurse nosync nounwind willreturn memory(none) uwtable "min-legal-vector-width"="128" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" } + + !llvm.module.flags = !{!0, !1, !2, !3} + !llvm.ident = !{!4} + + !0 = !{i32 1, !"wchar_size", i32 4} + !1 = !{i32 8, !"PIC Level", i32 2} + !2 = !{i32 7, !"PIE Level", i32 2} + !3 = !{i32 7, !"uwtable", i32 2} + !4 = !{!"clang version 17.0.6 (https://github.com/Kuznetsov-Artyom/llvm-nnsu-2024 a7816066a7b000bd8961dacdc49fc4d7b6c649f0)"} ... --- @@ -97,7 +75,7 @@ frameInfo: hasPatchPoint: false stackSize: 0 offsetAdjustment: 0 - maxAlignment: 16 + maxAlignment: 1 adjustsStack: false hasCalls: false stackProtector: '' @@ -112,16 +90,7 @@ frameInfo: savePoint: '' restorePoint: '' fixedStack: [] -stack: - - { id: 0, name: a.addr, type: default, offset: -32, size: 16, alignment: 16, - stack-id: default, callee-saved-register: '', callee-saved-restored: true, - debug-info-variable: '', debug-info-expression: '', debug-info-location: '' } - - { id: 1, name: b.addr, type: default, offset: -48, size: 16, alignment: 16, - stack-id: default, callee-saved-register: '', callee-saved-restored: true, - debug-info-variable: '', debug-info-expression: '', debug-info-location: '' } - - { id: 2, name: c.addr, type: default, offset: -64, size: 16, alignment: 16, - stack-id: default, callee-saved-register: '', callee-saved-restored: true, - debug-info-variable: '', debug-info-expression: '', debug-info-location: '' } +stack: [] entry_values: [] callSites: [] debugValueSubstitutions: [] @@ -131,9 +100,6 @@ body: | bb.0.entry: liveins: $xmm0, $xmm1, $xmm2 - MOVAPDmr $rsp, 1, $noreg, -24, $noreg, renamable $xmm0 :: (store (s128) into %ir.a.addr) - MOVAPDmr $rsp, 1, $noreg, -40, $noreg, renamable $xmm1 :: (store (s128) into %ir.b.addr) - MOVAPDmr $rsp, 1, $noreg, -56, $noreg, renamable $xmm2 :: (store (s128) into %ir.c.addr) $xmm0 = VFMADD213PDZ128r $xmm0, $xmm1, $xmm2, implicit $mxcsr RET64 $xmm0 @@ -169,7 +135,7 @@ frameInfo: hasPatchPoint: false stackSize: 0 offsetAdjustment: 0 - maxAlignment: 16 + maxAlignment: 1 adjustsStack: false hasCalls: false stackProtector: '' @@ -184,19 +150,7 @@ frameInfo: savePoint: '' restorePoint: '' fixedStack: [] -stack: - - { id: 0, name: a.addr, type: default, offset: -32, size: 16, alignment: 16, - stack-id: default, callee-saved-register: '', callee-saved-restored: true, - debug-info-variable: '', debug-info-expression: '', debug-info-location: '' } - - { id: 1, name: b.addr, type: default, offset: -48, size: 16, alignment: 16, - stack-id: default, callee-saved-register: '', callee-saved-restored: true, - debug-info-variable: '', debug-info-expression: '', debug-info-location: '' } - - { id: 2, name: c.addr, type: default, offset: -64, size: 16, alignment: 16, - stack-id: default, callee-saved-register: '', callee-saved-restored: true, - debug-info-variable: '', debug-info-expression: '', debug-info-location: '' } - - { id: 3, name: tmp, type: default, offset: -80, size: 16, alignment: 16, - stack-id: default, callee-saved-register: '', callee-saved-restored: true, - debug-info-variable: '', debug-info-expression: '', debug-info-location: '' } +stack: [] entry_values: [] callSites: [] debugValueSubstitutions: [] @@ -206,11 +160,7 @@ body: | bb.0.entry: liveins: $xmm0, $xmm1, $xmm2 - MOVAPDmr $rsp, 1, $noreg, -24, $noreg, renamable $xmm0 :: (store (s128) into %ir.a.addr) - MOVAPDmr $rsp, 1, $noreg, -40, $noreg, renamable $xmm1 :: (store (s128) into %ir.b.addr) - MOVAPDmr $rsp, 1, $noreg, -56, $noreg, renamable $xmm2 :: (store (s128) into %ir.c.addr) $xmm0 = VFMADD213PDZ128r $xmm0, $xmm1, $xmm2, implicit $mxcsr - MOVAPDmr $rsp, 1, $noreg, -72, $noreg, renamable $xmm0 :: (store (s128) into %ir.tmp) RET64 $xmm0 ... @@ -245,7 +195,7 @@ frameInfo: hasPatchPoint: false stackSize: 0 offsetAdjustment: 0 - maxAlignment: 16 + maxAlignment: 1 adjustsStack: false hasCalls: false stackProtector: '' @@ -260,19 +210,7 @@ frameInfo: savePoint: '' restorePoint: '' fixedStack: [] -stack: - - { id: 0, name: a.addr, type: default, offset: -32, size: 16, alignment: 16, - stack-id: default, callee-saved-register: '', callee-saved-restored: true, - debug-info-variable: '', debug-info-expression: '', debug-info-location: '' } - - { id: 1, name: b.addr, type: default, offset: -48, size: 16, alignment: 16, - stack-id: default, callee-saved-register: '', callee-saved-restored: true, - debug-info-variable: '', debug-info-expression: '', debug-info-location: '' } - - { id: 2, name: c.addr, type: default, offset: -64, size: 16, alignment: 16, - stack-id: default, callee-saved-register: '', callee-saved-restored: true, - debug-info-variable: '', debug-info-expression: '', debug-info-location: '' } - - { id: 3, name: tmp, type: default, offset: -80, size: 16, alignment: 16, - stack-id: default, callee-saved-register: '', callee-saved-restored: true, - debug-info-variable: '', debug-info-expression: '', debug-info-location: '' } +stack: [] entry_values: [] callSites: [] debugValueSubstitutions: [] @@ -282,11 +220,7 @@ body: | bb.0.entry: liveins: $xmm0, $xmm1, $xmm2 - MOVAPDmr $rsp, 1, $noreg, -24, $noreg, renamable $xmm0 :: (store (s128) into %ir.a.addr) - MOVAPDmr $rsp, 1, $noreg, -40, $noreg, renamable $xmm1 :: (store (s128) into %ir.b.addr) - MOVAPDmr $rsp, 1, $noreg, -56, $noreg, renamable $xmm2 :: (store (s128) into %ir.c.addr) $xmm0 = VFMADD213PDZ128r $xmm0, $xmm2, $xmm1, implicit $mxcsr - MOVAPDmr $rsp, 1, $noreg, -72, $noreg, renamable $xmm0 :: (store (s128) into %ir.tmp) $xmm0 = VFMADD213PDZ128r $xmm0, $xmm2, $xmm1, implicit $mxcsr RET64 $xmm0 diff --git a/llvm/test/lab3/kuznetsov_artyom/testing.mir b/llvm/test/lab3/kuznetsov_artyom/testing.mir new file mode 100644 index 0000000000000..cdc415a887396 --- /dev/null +++ b/llvm/test/lab3/kuznetsov_artyom/testing.mir @@ -0,0 +1,246 @@ +# RUN: llc -mtriple x86_64-unknown-linux-gnu -run-pass=x86-muladd %s -o - | FileCheck %s + +--- | + ; ModuleID = 'test.ll' + source_filename = "test.cpp" + target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" + target triple = "x86_64-unknown-linux-gnu" + + ; Function Attrs: mustprogress nofree nosync nounwind willreturn memory(none) uwtable + define dso_local noundef <2 x double> @_Z12muladd_test1Dv2_dS_S_(<2 x double> noundef %a, <2 x double> noundef %b, <2 x double> noundef %c) local_unnamed_addr #0 { + entry: + %0 = tail call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %a, <2 x double> %b, <2 x double> %c) + ret <2 x double> %0 + } + + ; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none) + declare <2 x double> @llvm.fmuladd.v2f64(<2 x double>, <2 x double>, <2 x double>) #1 + + ; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(none) uwtable + define dso_local noundef <2 x double> @_Z12muladd_test2Dv2_dS_S_(<2 x double> noundef %a, <2 x double> noundef %b, <2 x double> noundef %c) local_unnamed_addr #2 { + entry: + %mul = fmul <2 x double> %a, %b + %add = fadd <2 x double> %mul, %c + ret <2 x double> %add + } + + ; Function Attrs: mustprogress nofree nosync nounwind willreturn memory(none) uwtable + define dso_local noundef <2 x double> @_Z12muladd_test3Dv2_dS_S_(<2 x double> noundef %a, <2 x double> noundef %b, <2 x double> noundef %c) local_unnamed_addr #0 { + entry: + %0 = tail call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %a, <2 x double> %c, <2 x double> %b) + %1 = tail call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %0, <2 x double> %c, <2 x double> %b) + ret <2 x double> %1 + } + + attributes #0 = { mustprogress nofree nosync nounwind willreturn memory(none) uwtable "min-legal-vector-width"="128" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" } + attributes #1 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) } + attributes #2 = { mustprogress nofree norecurse nosync nounwind willreturn memory(none) uwtable "min-legal-vector-width"="128" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" } + + !llvm.module.flags = !{!0, !1, !2, !3} + !llvm.ident = !{!4} + + !0 = !{i32 1, !"wchar_size", i32 4} + !1 = !{i32 8, !"PIC Level", i32 2} + !2 = !{i32 7, !"PIE Level", i32 2} + !3 = !{i32 7, !"uwtable", i32 2} + !4 = !{!"clang version 17.0.6 (https://github.com/Kuznetsov-Artyom/llvm-nnsu-2024 a7816066a7b000bd8961dacdc49fc4d7b6c649f0)"} + +... +--- +name: _Z12muladd_test1Dv2_dS_S_ +alignment: 16 +exposesReturnsTwice: false +legalized: false +regBankSelected: false +selected: false +failedISel: false +tracksRegLiveness: true +hasWinCFI: false +callsEHReturn: false +callsUnwindInit: false +hasEHCatchret: false +hasEHScopes: false +hasEHFunclets: false +isOutlined: false +debugInstrRef: true +failsVerification: false +tracksDebugUserValues: true +registers: [] +liveins: + - { reg: '$xmm0', virtual-reg: '' } + - { reg: '$xmm1', virtual-reg: '' } + - { reg: '$xmm2', virtual-reg: '' } +frameInfo: + isFrameAddressTaken: false + isReturnAddressTaken: false + hasStackMap: false + hasPatchPoint: false + stackSize: 0 + offsetAdjustment: 0 + maxAlignment: 1 + adjustsStack: false + hasCalls: false + stackProtector: '' + functionContext: '' + maxCallFrameSize: 0 + cvBytesOfCalleeSavedRegisters: 0 + hasOpaqueSPAdjustment: false + hasVAStart: false + hasMustTailInVarArgFunc: false + hasTailCall: false + localFrameSize: 0 + savePoint: '' + restorePoint: '' +fixedStack: [] +stack: [] +entry_values: [] +callSites: [] +debugValueSubstitutions: [] +constants: [] +machineFunctionInfo: {} +body: | + bb.0.entry: + liveins: $xmm0, $xmm1, $xmm2 + + renamable $xmm0 = nofpexcept MULPDrr killed renamable $xmm0, killed renamable $xmm1, implicit $mxcsr + renamable $xmm0 = nofpexcept ADDPDrr killed renamable $xmm0, killed renamable $xmm2, implicit $mxcsr + RET64 $xmm0 + + ; CHECK: liveins: $xmm0, $xmm1, $xmm2 + ; CHECK: $xmm0 = VFMADD213PDZ128r $xmm0, $xmm1, $xmm2, implicit $mxcsr + ; CHECK: RET64 $xmm0 + +... +--- +name: _Z12muladd_test2Dv2_dS_S_ +alignment: 16 +exposesReturnsTwice: false +legalized: false +regBankSelected: false +selected: false +failedISel: false +tracksRegLiveness: true +hasWinCFI: false +callsEHReturn: false +callsUnwindInit: false +hasEHCatchret: false +hasEHScopes: false +hasEHFunclets: false +isOutlined: false +debugInstrRef: true +failsVerification: false +tracksDebugUserValues: true +registers: [] +liveins: + - { reg: '$xmm0', virtual-reg: '' } + - { reg: '$xmm1', virtual-reg: '' } + - { reg: '$xmm2', virtual-reg: '' } +frameInfo: + isFrameAddressTaken: false + isReturnAddressTaken: false + hasStackMap: false + hasPatchPoint: false + stackSize: 0 + offsetAdjustment: 0 + maxAlignment: 1 + adjustsStack: false + hasCalls: false + stackProtector: '' + functionContext: '' + maxCallFrameSize: 0 + cvBytesOfCalleeSavedRegisters: 0 + hasOpaqueSPAdjustment: false + hasVAStart: false + hasMustTailInVarArgFunc: false + hasTailCall: false + localFrameSize: 0 + savePoint: '' + restorePoint: '' +fixedStack: [] +stack: [] +entry_values: [] +callSites: [] +debugValueSubstitutions: [] +constants: [] +machineFunctionInfo: {} +body: | + bb.0.entry: + liveins: $xmm0, $xmm1, $xmm2 + + renamable $xmm0 = nofpexcept MULPDrr killed renamable $xmm0, killed renamable $xmm1, implicit $mxcsr + renamable $xmm0 = nofpexcept ADDPDrr killed renamable $xmm0, killed renamable $xmm2, implicit $mxcsr + RET64 $xmm0 + + ; CHECK: liveins: $xmm0, $xmm1, $xmm2 + ; CHECK: $xmm0 = VFMADD213PDZ128r $xmm0, $xmm1, $xmm2, implicit $mxcsr + ; CHECK: RET64 $xmm0 + +... +--- +name: _Z12muladd_test3Dv2_dS_S_ +alignment: 16 +exposesReturnsTwice: false +legalized: false +regBankSelected: false +selected: false +failedISel: false +tracksRegLiveness: true +hasWinCFI: false +callsEHReturn: false +callsUnwindInit: false +hasEHCatchret: false +hasEHScopes: false +hasEHFunclets: false +isOutlined: false +debugInstrRef: true +failsVerification: false +tracksDebugUserValues: true +registers: [] +liveins: + - { reg: '$xmm0', virtual-reg: '' } + - { reg: '$xmm1', virtual-reg: '' } + - { reg: '$xmm2', virtual-reg: '' } +frameInfo: + isFrameAddressTaken: false + isReturnAddressTaken: false + hasStackMap: false + hasPatchPoint: false + stackSize: 0 + offsetAdjustment: 0 + maxAlignment: 1 + adjustsStack: false + hasCalls: false + stackProtector: '' + functionContext: '' + maxCallFrameSize: 0 + cvBytesOfCalleeSavedRegisters: 0 + hasOpaqueSPAdjustment: false + hasVAStart: false + hasMustTailInVarArgFunc: false + hasTailCall: false + localFrameSize: 0 + savePoint: '' + restorePoint: '' +fixedStack: [] +stack: [] +entry_values: [] +callSites: [] +debugValueSubstitutions: [] +constants: [] +machineFunctionInfo: {} +body: | + bb.0.entry: + liveins: $xmm0, $xmm1, $xmm2 + + renamable $xmm0 = nofpexcept MULPDrr killed renamable $xmm0, renamable $xmm2, implicit $mxcsr + renamable $xmm0 = nofpexcept ADDPDrr killed renamable $xmm0, renamable $xmm1, implicit $mxcsr + renamable $xmm0 = nofpexcept MULPDrr killed renamable $xmm0, killed renamable $xmm2, implicit $mxcsr + renamable $xmm0 = nofpexcept ADDPDrr killed renamable $xmm0, killed renamable $xmm1, implicit $mxcsr + RET64 $xmm0 + + ; CHECK: liveins: $xmm0, $xmm1, $xmm2 + ; CHECK: $xmm0 = VFMADD213PDZ128r $xmm0, $xmm2, $xmm1, implicit $mxcsr + ; CHECK: $xmm0 = VFMADD213PDZ128r $xmm0, $xmm2, $xmm1, implicit $mxcsr + ; CHECK: RET64 $xmm0 + +... From 84554d49ab660d00ba94d42233621b07ed285c65 Mon Sep 17 00:00:00 2001 From: Kuznetsov-Artyom Date: Sun, 21 Apr 2024 00:57:30 +0300 Subject: [PATCH 03/10] finish --- llvm/lib/Target/X86/X86MulAddPass.cpp | 79 +++---- llvm/test/lab3/kuznetsov_artyom/test.cpp | 14 -- llvm/test/lab3/kuznetsov_artyom/test_ll.ll | 43 ---- llvm/test/lab3/kuznetsov_artyom/test_out.mir | 227 ------------------- llvm/test/lab3/kuznetsov_artyom/testing.mir | 49 +++- 5 files changed, 84 insertions(+), 328 deletions(-) delete mode 100644 llvm/test/lab3/kuznetsov_artyom/test.cpp delete mode 100644 llvm/test/lab3/kuznetsov_artyom/test_ll.ll delete mode 100644 llvm/test/lab3/kuznetsov_artyom/test_out.mir diff --git a/llvm/lib/Target/X86/X86MulAddPass.cpp b/llvm/lib/Target/X86/X86MulAddPass.cpp index 1a0c7e374503f..0cc0f54d04600 100644 --- a/llvm/lib/Target/X86/X86MulAddPass.cpp +++ b/llvm/lib/Target/X86/X86MulAddPass.cpp @@ -1,4 +1,5 @@ #include "X86.h" +#include "X86.h" #include "X86InstrInfo.h" #include "X86Subtarget.h" #include "llvm/CodeGen/MachineFunctionPass.h" @@ -6,62 +7,62 @@ using namespace llvm; -#define X86_MULADD_PASS_NAME "My custom X86 muladd pass" +#define X86_MULADD_PASS_DESC "X86 muladd pass" +#define X86_MULADD_PASS_NAME "x86-muladd" namespace { class X86MulAddPass : public MachineFunctionPass { public: - static char ID; + static char ID; - X86MulAddPass() : MachineFunctionPass(ID) { - initializeX86MulAddPassPass(*PassRegistry::getPassRegistry()); - } + X86MulAddPass() : MachineFunctionPass(ID) { + initializeX86MulAddPassPass(*PassRegistry::getPassRegistry()); + } - bool runOnMachineFunction(MachineFunction &MF) override; + bool runOnMachineFunction(MachineFunction &MF) override; - StringRef getPassName() const override { return X86_MULADD_PASS_NAME; } + StringRef getPassName() const override { return X86_MULADD_PASS_DESC; } }; char X86MulAddPass::ID = 0; -bool X86MulAddPass::runOnMachineFunction(MachineFunction &MF) { - const TargetInstrInfo *TII = MF.getSubtarget().getInstrInfo(); +bool X86MulAddPass::runOnMachineFunction(MachineFunction &machineFunc) { + const TargetInstrInfo *instrInfo = machineFunc.getSubtarget().getInstrInfo(); + bool changed = false; - for (auto &MBB : MF) { - for (auto I = MBB.begin(); I != MBB.end(); I++) { - // Found multiply operation - if (I->getOpcode() == X86::MULPDrr) { - auto MulInstr = I; - auto NextInstr = std::next(MulInstr); - // And next operation is add - if (NextInstr->getOpcode() == X86::ADDPDrr) { - if (MulInstr->getOperand(0).getReg() == NextInstr->getOperand(1).getReg()) { - I--; - MachineInstr &MI = *MulInstr; - MachineInstrBuilder MIB = BuildMI(MBB, MI, MI.getDebugLoc(), TII->get(X86::VFMADD213PDZ128r)); - MIB.addReg(NextInstr->getOperand(0).getReg(), RegState::Define); - MIB.addReg(MulInstr->getOperand(1).getReg()); - MIB.addReg(MulInstr->getOperand(2).getReg()); - MIB.addReg(NextInstr->getOperand(2).getReg()); - MulInstr->eraseFromParent(); - NextInstr->eraseFromParent(); - } - } - } + for (auto &block : machineFunc) { + for (auto it = block.begin(); it != block.end(); ++it) { + if (it->getOpcode() == X86::MULPDrr) { + auto instrMul = it; + auto instrNext = std::next(instrMul); + if (instrNext->getOpcode() == X86::ADDPDrr) { + if (instrMul->getOperand(0).getReg() == + instrNext->getOperand(1).getReg()) { + --it; + MachineInstr &MI = *instrMul; + MachineInstrBuilder MIB = BuildMI(block, MI, MI.getDebugLoc(), + instrInfo->get(X86::VFMADD213PDZ128r)); + MIB.addReg(instrNext->getOperand(0).getReg(), RegState::Define); + MIB.addReg(instrMul->getOperand(1).getReg()); + MIB.addReg(instrMul->getOperand(2).getReg()); + MIB.addReg(instrNext->getOperand(2).getReg()); + instrMul->eraseFromParent(); + instrNext->eraseFromParent(); + changed = true; + } } + } } + } - return false; + return changed; } -} // end of anonymous namespace +} // namespace -INITIALIZE_PASS(X86MulAddPass, "x86-muladd", - X86_MULADD_PASS_NAME, - false, // is CFG only? - false // is analysis? -) +INITIALIZE_PASS(X86MulAddPass, X86_MULADD_PASS_NAME, X86_MULADD_PASS_NAME, + false, false) namespace llvm { - FunctionPass *createX86MulAddPassPass() { return new X86MulAddPass(); } -} \ No newline at end of file +FunctionPass *createX86MulAddPassPass() { return new X86MulAddPass(); } +} // namespace llvm \ No newline at end of file diff --git a/llvm/test/lab3/kuznetsov_artyom/test.cpp b/llvm/test/lab3/kuznetsov_artyom/test.cpp deleted file mode 100644 index 41c761ed6ef69..0000000000000 --- a/llvm/test/lab3/kuznetsov_artyom/test.cpp +++ /dev/null @@ -1,14 +0,0 @@ -#include - -__m128d muladd_test1(__m128d a, __m128d b, __m128d c) { return a * b + c; } - -__m128d muladd_test2(__m128d a, __m128d b, __m128d c) { - __m128d tmp = a * b; - tmp = tmp + c; - return tmp; -} - -__m128d muladd_test3(__m128d a, __m128d b, __m128d c) { - __m128d tmp = a * c + b; - return tmp * c + b; -} diff --git a/llvm/test/lab3/kuznetsov_artyom/test_ll.ll b/llvm/test/lab3/kuznetsov_artyom/test_ll.ll deleted file mode 100644 index 01e65938a0fa3..0000000000000 --- a/llvm/test/lab3/kuznetsov_artyom/test_ll.ll +++ /dev/null @@ -1,43 +0,0 @@ -; ModuleID = 'test.cpp' -source_filename = "test.cpp" -target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" -target triple = "x86_64-unknown-linux-gnu" - -; Function Attrs: mustprogress nofree nosync nounwind willreturn memory(none) uwtable -define dso_local noundef <2 x double> @_Z12muladd_test1Dv2_dS_S_(<2 x double> noundef %a, <2 x double> noundef %b, <2 x double> noundef %c) local_unnamed_addr #0 { -entry: - %0 = tail call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %a, <2 x double> %b, <2 x double> %c) - ret <2 x double> %0 -} - -; Function Attrs: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) -declare <2 x double> @llvm.fmuladd.v2f64(<2 x double>, <2 x double>, <2 x double>) #1 - -; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(none) uwtable -define dso_local noundef <2 x double> @_Z12muladd_test2Dv2_dS_S_(<2 x double> noundef %a, <2 x double> noundef %b, <2 x double> noundef %c) local_unnamed_addr #2 { -entry: - %mul = fmul <2 x double> %a, %b - %add = fadd <2 x double> %mul, %c - ret <2 x double> %add -} - -; Function Attrs: mustprogress nofree nosync nounwind willreturn memory(none) uwtable -define dso_local noundef <2 x double> @_Z12muladd_test3Dv2_dS_S_(<2 x double> noundef %a, <2 x double> noundef %b, <2 x double> noundef %c) local_unnamed_addr #0 { -entry: - %0 = tail call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %a, <2 x double> %c, <2 x double> %b) - %1 = tail call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %0, <2 x double> %c, <2 x double> %b) - ret <2 x double> %1 -} - -attributes #0 = { mustprogress nofree nosync nounwind willreturn memory(none) uwtable "min-legal-vector-width"="128" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" } -attributes #1 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) } -attributes #2 = { mustprogress nofree norecurse nosync nounwind willreturn memory(none) uwtable "min-legal-vector-width"="128" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" } - -!llvm.module.flags = !{!0, !1, !2, !3} -!llvm.ident = !{!4} - -!0 = !{i32 1, !"wchar_size", i32 4} -!1 = !{i32 8, !"PIC Level", i32 2} -!2 = !{i32 7, !"PIE Level", i32 2} -!3 = !{i32 7, !"uwtable", i32 2} -!4 = !{!"clang version 17.0.6 (https://github.com/Kuznetsov-Artyom/llvm-nnsu-2024 a7816066a7b000bd8961dacdc49fc4d7b6c649f0)"} diff --git a/llvm/test/lab3/kuznetsov_artyom/test_out.mir b/llvm/test/lab3/kuznetsov_artyom/test_out.mir deleted file mode 100644 index e83a35e36dbb9..0000000000000 --- a/llvm/test/lab3/kuznetsov_artyom/test_out.mir +++ /dev/null @@ -1,227 +0,0 @@ ---- | - ; ModuleID = 'test.mir' - source_filename = "test.cpp" - target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" - target triple = "x86_64-unknown-linux-gnu" - - ; Function Attrs: mustprogress nofree nosync nounwind willreturn memory(none) uwtable - define dso_local noundef <2 x double> @_Z12muladd_test1Dv2_dS_S_(<2 x double> noundef %a, <2 x double> noundef %b, <2 x double> noundef %c) local_unnamed_addr #0 { - entry: - %0 = tail call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %a, <2 x double> %b, <2 x double> %c) - ret <2 x double> %0 - } - - ; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none) - declare <2 x double> @llvm.fmuladd.v2f64(<2 x double>, <2 x double>, <2 x double>) #1 - - ; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(none) uwtable - define dso_local noundef <2 x double> @_Z12muladd_test2Dv2_dS_S_(<2 x double> noundef %a, <2 x double> noundef %b, <2 x double> noundef %c) local_unnamed_addr #2 { - entry: - %mul = fmul <2 x double> %a, %b - %add = fadd <2 x double> %mul, %c - ret <2 x double> %add - } - - ; Function Attrs: mustprogress nofree nosync nounwind willreturn memory(none) uwtable - define dso_local noundef <2 x double> @_Z12muladd_test3Dv2_dS_S_(<2 x double> noundef %a, <2 x double> noundef %b, <2 x double> noundef %c) local_unnamed_addr #0 { - entry: - %0 = tail call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %a, <2 x double> %c, <2 x double> %b) - %1 = tail call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %0, <2 x double> %c, <2 x double> %b) - ret <2 x double> %1 - } - - attributes #0 = { mustprogress nofree nosync nounwind willreturn memory(none) uwtable "min-legal-vector-width"="128" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" } - attributes #1 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) } - attributes #2 = { mustprogress nofree norecurse nosync nounwind willreturn memory(none) uwtable "min-legal-vector-width"="128" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" } - - !llvm.module.flags = !{!0, !1, !2, !3} - !llvm.ident = !{!4} - - !0 = !{i32 1, !"wchar_size", i32 4} - !1 = !{i32 8, !"PIC Level", i32 2} - !2 = !{i32 7, !"PIE Level", i32 2} - !3 = !{i32 7, !"uwtable", i32 2} - !4 = !{!"clang version 17.0.6 (https://github.com/Kuznetsov-Artyom/llvm-nnsu-2024 a7816066a7b000bd8961dacdc49fc4d7b6c649f0)"} - -... ---- -name: _Z12muladd_test1Dv2_dS_S_ -alignment: 16 -exposesReturnsTwice: false -legalized: false -regBankSelected: false -selected: false -failedISel: false -tracksRegLiveness: true -hasWinCFI: false -callsEHReturn: false -callsUnwindInit: false -hasEHCatchret: false -hasEHScopes: false -hasEHFunclets: false -isOutlined: false -debugInstrRef: true -failsVerification: false -tracksDebugUserValues: true -registers: [] -liveins: - - { reg: '$xmm0', virtual-reg: '' } - - { reg: '$xmm1', virtual-reg: '' } - - { reg: '$xmm2', virtual-reg: '' } -frameInfo: - isFrameAddressTaken: false - isReturnAddressTaken: false - hasStackMap: false - hasPatchPoint: false - stackSize: 0 - offsetAdjustment: 0 - maxAlignment: 1 - adjustsStack: false - hasCalls: false - stackProtector: '' - functionContext: '' - maxCallFrameSize: 0 - cvBytesOfCalleeSavedRegisters: 0 - hasOpaqueSPAdjustment: false - hasVAStart: false - hasMustTailInVarArgFunc: false - hasTailCall: false - localFrameSize: 0 - savePoint: '' - restorePoint: '' -fixedStack: [] -stack: [] -entry_values: [] -callSites: [] -debugValueSubstitutions: [] -constants: [] -machineFunctionInfo: {} -body: | - bb.0.entry: - liveins: $xmm0, $xmm1, $xmm2 - - $xmm0 = VFMADD213PDZ128r $xmm0, $xmm1, $xmm2, implicit $mxcsr - RET64 $xmm0 - -... ---- -name: _Z12muladd_test2Dv2_dS_S_ -alignment: 16 -exposesReturnsTwice: false -legalized: false -regBankSelected: false -selected: false -failedISel: false -tracksRegLiveness: true -hasWinCFI: false -callsEHReturn: false -callsUnwindInit: false -hasEHCatchret: false -hasEHScopes: false -hasEHFunclets: false -isOutlined: false -debugInstrRef: true -failsVerification: false -tracksDebugUserValues: true -registers: [] -liveins: - - { reg: '$xmm0', virtual-reg: '' } - - { reg: '$xmm1', virtual-reg: '' } - - { reg: '$xmm2', virtual-reg: '' } -frameInfo: - isFrameAddressTaken: false - isReturnAddressTaken: false - hasStackMap: false - hasPatchPoint: false - stackSize: 0 - offsetAdjustment: 0 - maxAlignment: 1 - adjustsStack: false - hasCalls: false - stackProtector: '' - functionContext: '' - maxCallFrameSize: 0 - cvBytesOfCalleeSavedRegisters: 0 - hasOpaqueSPAdjustment: false - hasVAStart: false - hasMustTailInVarArgFunc: false - hasTailCall: false - localFrameSize: 0 - savePoint: '' - restorePoint: '' -fixedStack: [] -stack: [] -entry_values: [] -callSites: [] -debugValueSubstitutions: [] -constants: [] -machineFunctionInfo: {} -body: | - bb.0.entry: - liveins: $xmm0, $xmm1, $xmm2 - - $xmm0 = VFMADD213PDZ128r $xmm0, $xmm1, $xmm2, implicit $mxcsr - RET64 $xmm0 - -... ---- -name: _Z12muladd_test3Dv2_dS_S_ -alignment: 16 -exposesReturnsTwice: false -legalized: false -regBankSelected: false -selected: false -failedISel: false -tracksRegLiveness: true -hasWinCFI: false -callsEHReturn: false -callsUnwindInit: false -hasEHCatchret: false -hasEHScopes: false -hasEHFunclets: false -isOutlined: false -debugInstrRef: true -failsVerification: false -tracksDebugUserValues: true -registers: [] -liveins: - - { reg: '$xmm0', virtual-reg: '' } - - { reg: '$xmm1', virtual-reg: '' } - - { reg: '$xmm2', virtual-reg: '' } -frameInfo: - isFrameAddressTaken: false - isReturnAddressTaken: false - hasStackMap: false - hasPatchPoint: false - stackSize: 0 - offsetAdjustment: 0 - maxAlignment: 1 - adjustsStack: false - hasCalls: false - stackProtector: '' - functionContext: '' - maxCallFrameSize: 0 - cvBytesOfCalleeSavedRegisters: 0 - hasOpaqueSPAdjustment: false - hasVAStart: false - hasMustTailInVarArgFunc: false - hasTailCall: false - localFrameSize: 0 - savePoint: '' - restorePoint: '' -fixedStack: [] -stack: [] -entry_values: [] -callSites: [] -debugValueSubstitutions: [] -constants: [] -machineFunctionInfo: {} -body: | - bb.0.entry: - liveins: $xmm0, $xmm1, $xmm2 - - $xmm0 = VFMADD213PDZ128r $xmm0, $xmm2, $xmm1, implicit $mxcsr - $xmm0 = VFMADD213PDZ128r $xmm0, $xmm2, $xmm1, implicit $mxcsr - RET64 $xmm0 - -... diff --git a/llvm/test/lab3/kuznetsov_artyom/testing.mir b/llvm/test/lab3/kuznetsov_artyom/testing.mir index cdc415a887396..364cc786eda54 100644 --- a/llvm/test/lab3/kuznetsov_artyom/testing.mir +++ b/llvm/test/lab3/kuznetsov_artyom/testing.mir @@ -1,5 +1,21 @@ # RUN: llc -mtriple x86_64-unknown-linux-gnu -run-pass=x86-muladd %s -o - | FileCheck %s +# test.cpp + +# __m128d muladd_test1(__m128d a, __m128d b, __m128d c) { return a * b + c; } + +# __m128d muladd_test2(__m128d a, __m128d b, __m128d c) { +# __m128d tmp = a * b; +# tmp = tmp + c; +# return tmp; +# } + +# __m128d muladd_test3(__m128d a, __m128d b, __m128d c) { +# __m128d tmp = a * c + b; +# return tmp * c + b; +# } + + --- | ; ModuleID = 'test.ll' source_filename = "test.cpp" @@ -107,8 +123,14 @@ body: | RET64 $xmm0 ; CHECK: liveins: $xmm0, $xmm1, $xmm2 + + ; CHECK-NOT: renamable $xmm0 = nofpexcept MULPDrr killed renamable $xmm0, killed renamable $xmm1, implicit $mxcsr + ; CHECK-NOT: renamable $xmm0 = nofpexcept ADDPDrr killed renamable $xmm0, killed renamable $xmm2, implicit $mxcsr ; CHECK: $xmm0 = VFMADD213PDZ128r $xmm0, $xmm1, $xmm2, implicit $mxcsr - ; CHECK: RET64 $xmm0 + ; CHECK-NOT: renamable $xmm0 = nofpexcept MULPDrr killed renamable $xmm0, killed renamable $xmm1, implicit $mxcsr + ; CHECK-NOT: renamable $xmm0 = nofpexcept ADDPDrr killed renamable $xmm0, killed renamable $xmm2, implicit $mxcsr + + ; CHECK-NEXT: RET64 $xmm0 ... --- @@ -172,8 +194,14 @@ body: | RET64 $xmm0 ; CHECK: liveins: $xmm0, $xmm1, $xmm2 + + ; CHECK-NOT: renamable $xmm0 = nofpexcept MULPDrr killed renamable $xmm0, killed renamable $xmm1, implicit $mxcsr + ; CHECK-NOT: renamable $xmm0 = nofpexcept ADDPDrr killed renamable $xmm0, killed renamable $xmm2, implicit $mxcsr ; CHECK: $xmm0 = VFMADD213PDZ128r $xmm0, $xmm1, $xmm2, implicit $mxcsr - ; CHECK: RET64 $xmm0 + ; CHECK-NOT: renamable $xmm0 = nofpexcept MULPDrr killed renamable $xmm0, killed renamable $xmm1, implicit $mxcsr + ; CHECK-NOT: renamable $xmm0 = nofpexcept ADDPDrr killed renamable $xmm0, killed renamable $xmm2, implicit $mxcsr + + ; CHECK-NEXT: RET64 $xmm0 ... --- @@ -237,10 +265,21 @@ body: | renamable $xmm0 = nofpexcept MULPDrr killed renamable $xmm0, killed renamable $xmm2, implicit $mxcsr renamable $xmm0 = nofpexcept ADDPDrr killed renamable $xmm0, killed renamable $xmm1, implicit $mxcsr RET64 $xmm0 - + ; CHECK: liveins: $xmm0, $xmm1, $xmm2 + + ; CHECK-NOT: renamable $xmm0 = nofpexcept MULPDrr killed renamable $xmm0, renamable $xmm2, implicit $mxcsr + ; CHECK-NOT: renamable $xmm0 = nofpexcept ADDPDrr killed renamable $xmm0, renamable $xmm1, implicit $mxcsr ; CHECK: $xmm0 = VFMADD213PDZ128r $xmm0, $xmm2, $xmm1, implicit $mxcsr - ; CHECK: $xmm0 = VFMADD213PDZ128r $xmm0, $xmm2, $xmm1, implicit $mxcsr - ; CHECK: RET64 $xmm0 + ; CHECK-NOT: renamable $xmm0 = nofpexcept MULPDrr killed renamable $xmm0, renamable $xmm2, implicit $mxcsr + ; CHECK-NOT: renamable $xmm0 = nofpexcept ADDPDrr killed renamable $xmm0, renamable $xmm1, implicit $mxcsr + + ; CHECK-NOT: renamable $xmm0 = nofpexcept MULPDrr killed renamable $xmm0, killed renamable $xmm2, implicit $mxcsr + ; CHECK-NOT: renamable $xmm0 = nofpexcept ADDPDrr killed renamable $xmm0, killed renamable $xmm1, implicit $mxcsr + ; CHECK-NEXT: $xmm0 = VFMADD213PDZ128r $xmm0, $xmm2, $xmm1, implicit $mxcsr + ; CHECK-NOT: renamable $xmm0 = nofpexcept MULPDrr killed renamable $xmm0, renamable $xmm2, implicit $mxcsr + ; CHECK-NOT: renamable $xmm0 = nofpexcept ADDPDrr killed renamable $xmm0, renamable $xmm1, implicit $mxcsr + + ; CHECK-NEXT: RET64 $xmm0 ... From c694a46c1eae1bb08adcdf935ac4562bafeef49f Mon Sep 17 00:00:00 2001 From: Kuznetsov-Artyom Date: Sun, 21 Apr 2024 01:40:27 +0300 Subject: [PATCH 04/10] change --- llvm/lib/Target/X86/X86MulAddPass.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/llvm/lib/Target/X86/X86MulAddPass.cpp b/llvm/lib/Target/X86/X86MulAddPass.cpp index 0cc0f54d04600..2d805987e0d3a 100644 --- a/llvm/lib/Target/X86/X86MulAddPass.cpp +++ b/llvm/lib/Target/X86/X86MulAddPass.cpp @@ -1,5 +1,4 @@ #include "X86.h" -#include "X86.h" #include "X86InstrInfo.h" #include "X86Subtarget.h" #include "llvm/CodeGen/MachineFunctionPass.h" From d0378b668d4e9e7b60a19069049f55c257d8a3bf Mon Sep 17 00:00:00 2001 From: Kuznetsov-Artyom Date: Sun, 21 Apr 2024 13:56:44 +0300 Subject: [PATCH 05/10] fix style --- llvm/lib/Target/X86/X86MulAddPass.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/llvm/lib/Target/X86/X86MulAddPass.cpp b/llvm/lib/Target/X86/X86MulAddPass.cpp index 2d805987e0d3a..0ac007270a2b5 100644 --- a/llvm/lib/Target/X86/X86MulAddPass.cpp +++ b/llvm/lib/Target/X86/X86MulAddPass.cpp @@ -39,8 +39,9 @@ bool X86MulAddPass::runOnMachineFunction(MachineFunction &machineFunc) { instrNext->getOperand(1).getReg()) { --it; MachineInstr &MI = *instrMul; - MachineInstrBuilder MIB = BuildMI(block, MI, MI.getDebugLoc(), - instrInfo->get(X86::VFMADD213PDZ128r)); + MachineInstrBuilder MIB = + BuildMI(block, MI, MI.getDebugLoc(), + instrInfo->get(X86::VFMADD213PDZ128r)); MIB.addReg(instrNext->getOperand(0).getReg(), RegState::Define); MIB.addReg(instrMul->getOperand(1).getReg()); MIB.addReg(instrMul->getOperand(2).getReg()); From a12537d116efbcff985a056287fb27f58181db33 Mon Sep 17 00:00:00 2001 From: Kuznetsov-Artyom Date: Tue, 23 Apr 2024 03:06:58 +0300 Subject: [PATCH 06/10] update --- llvm/lib/Target/X86/X86MulAddPass.cpp | 59 ++- llvm/test/lab3/kuznetsov_artyom/test.cpp | 30 ++ llvm/test/lab3/kuznetsov_artyom/test.ll | 71 +++ llvm/test/lab3/kuznetsov_artyom/test.mir | 447 +++++++++++++++++++ llvm/test/lab3/kuznetsov_artyom/test_out.mir | 442 ++++++++++++++++++ 5 files changed, 1029 insertions(+), 20 deletions(-) create mode 100644 llvm/test/lab3/kuznetsov_artyom/test.cpp create mode 100644 llvm/test/lab3/kuznetsov_artyom/test.ll create mode 100644 llvm/test/lab3/kuznetsov_artyom/test.mir create mode 100644 llvm/test/lab3/kuznetsov_artyom/test_out.mir diff --git a/llvm/lib/Target/X86/X86MulAddPass.cpp b/llvm/lib/Target/X86/X86MulAddPass.cpp index 0ac007270a2b5..e551aa6a489ab 100644 --- a/llvm/lib/Target/X86/X86MulAddPass.cpp +++ b/llvm/lib/Target/X86/X86MulAddPass.cpp @@ -3,6 +3,8 @@ #include "X86Subtarget.h" #include "llvm/CodeGen/MachineFunctionPass.h" #include "llvm/CodeGen/MachineInstrBuilder.h" +#include +#include using namespace llvm; @@ -29,32 +31,49 @@ bool X86MulAddPass::runOnMachineFunction(MachineFunction &machineFunc) { const TargetInstrInfo *instrInfo = machineFunc.getSubtarget().getInstrInfo(); bool changed = false; + std::vector> deletedInstructions; + + llvm::outs() << machineFunc.getName() << '\n'; + for (auto &block : machineFunc) { - for (auto it = block.begin(); it != block.end(); ++it) { - if (it->getOpcode() == X86::MULPDrr) { - auto instrMul = it; - auto instrNext = std::next(instrMul); - if (instrNext->getOpcode() == X86::ADDPDrr) { - if (instrMul->getOperand(0).getReg() == - instrNext->getOperand(1).getReg()) { - --it; - MachineInstr &MI = *instrMul; - MachineInstrBuilder MIB = - BuildMI(block, MI, MI.getDebugLoc(), - instrInfo->get(X86::VFMADD213PDZ128r)); - MIB.addReg(instrNext->getOperand(0).getReg(), RegState::Define); - MIB.addReg(instrMul->getOperand(1).getReg()); - MIB.addReg(instrMul->getOperand(2).getReg()); - MIB.addReg(instrNext->getOperand(2).getReg()); - instrMul->eraseFromParent(); - instrNext->eraseFromParent(); - changed = true; - } + MachineInstr *mulInstr = nullptr; + MachineInstr *addInstr = nullptr; + + for (auto op = block.begin(); op != block.end(); ++op) { + if (op->getOpcode() == X86::MULPDrr) { + mulInstr = &(*op); + + for (auto opNext = std::next(op); opNext != block.end(); ++opNext) { + if (opNext->getOpcode() == X86::ADDPDrr) { + addInstr = &(*opNext); + + if (mulInstr->getOperand(0).getReg() == + addInstr->getOperand(1).getReg()) { + deletedInstructions.emplace_back(mulInstr, addInstr); + changed = true; + break; + } + } else if (opNext->definesRegister(mulInstr->getOperand(0).getReg())) + break; } } } } + for (auto &[mulInstr, addInstr] : deletedInstructions) { + MachineInstrBuilder MIB = + BuildMI(*mulInstr->getParent(), *mulInstr, mulInstr->getDebugLoc(), + instrInfo->get(X86::VFMADD213PDZ128r)); + + MIB.addReg(addInstr->getOperand(0).getReg(), RegState::Define); + MIB.addReg(mulInstr->getOperand(1).getReg()); + MIB.addReg(mulInstr->getOperand(2).getReg()); + MIB.addReg(addInstr->getOperand(2).getReg()); + + mulInstr->eraseFromParent(); + addInstr->eraseFromParent(); + } + return changed; } diff --git a/llvm/test/lab3/kuznetsov_artyom/test.cpp b/llvm/test/lab3/kuznetsov_artyom/test.cpp new file mode 100644 index 0000000000000..a39e5ac13d3b7 --- /dev/null +++ b/llvm/test/lab3/kuznetsov_artyom/test.cpp @@ -0,0 +1,30 @@ +#include + +__m128d muladd_test1(__m128d a, __m128d b, __m128d c) { return a * b + c; } // + + +__m128d muladd_test2(__m128d a, __m128d b, __m128d c) { // + + __m128d tmp = a * b; + tmp = tmp + c; + return tmp; +} + +__m128d muladd_test3(__m128d a, __m128d b, __m128d c) { // + + __m128d tmp = a * c + b; + return tmp * c + b; +} + +__m128d muladd_test4(__m128d a, __m128d b, __m128d c) { // - + __m128d tmp = a * c; + tmp = tmp / b; + return tmp + b; +} +__m128d muladd_test5(__m128d a, __m128d b, __m128d c) { + __m128d tmp = a * b; + __m128d tmp2 = b + a - c; + return tmp + c + tmp2; +} +__m128d muladd_test6(__m128d a, __m128d b, __m128d c) { + __m128d tmp = a * b; + __m128d tmp2 = tmp + c; + return tmp * c; +} diff --git a/llvm/test/lab3/kuznetsov_artyom/test.ll b/llvm/test/lab3/kuznetsov_artyom/test.ll new file mode 100644 index 0000000000000..03f95814823fe --- /dev/null +++ b/llvm/test/lab3/kuznetsov_artyom/test.ll @@ -0,0 +1,71 @@ +; ModuleID = 'test.cpp' +source_filename = "test.cpp" +target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" +target triple = "x86_64-unknown-linux-gnu" + +; Function Attrs: mustprogress nofree nosync nounwind willreturn memory(none) uwtable +define dso_local noundef <2 x double> @_Z12muladd_test1Dv2_dS_S_(<2 x double> noundef %a, <2 x double> noundef %b, <2 x double> noundef %c) local_unnamed_addr #0 { +entry: + %0 = tail call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %a, <2 x double> %b, <2 x double> %c) + ret <2 x double> %0 +} + +; Function Attrs: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) +declare <2 x double> @llvm.fmuladd.v2f64(<2 x double>, <2 x double>, <2 x double>) #1 + +; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(none) uwtable +define dso_local noundef <2 x double> @_Z12muladd_test2Dv2_dS_S_(<2 x double> noundef %a, <2 x double> noundef %b, <2 x double> noundef %c) local_unnamed_addr #2 { +entry: + %mul = fmul <2 x double> %a, %b + %add = fadd <2 x double> %mul, %c + ret <2 x double> %add +} + +; Function Attrs: mustprogress nofree nosync nounwind willreturn memory(none) uwtable +define dso_local noundef <2 x double> @_Z12muladd_test3Dv2_dS_S_(<2 x double> noundef %a, <2 x double> noundef %b, <2 x double> noundef %c) local_unnamed_addr #0 { +entry: + %0 = tail call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %a, <2 x double> %c, <2 x double> %b) + %1 = tail call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %0, <2 x double> %c, <2 x double> %b) + ret <2 x double> %1 +} + +; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(none) uwtable +define dso_local noundef <2 x double> @_Z12muladd_test4Dv2_dS_S_(<2 x double> noundef %a, <2 x double> noundef %b, <2 x double> noundef %c) local_unnamed_addr #2 { +entry: + %mul = fmul <2 x double> %a, %c + %div = fdiv <2 x double> %mul, %b + %add = fadd <2 x double> %div, %b + ret <2 x double> %add +} + +; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(none) uwtable +define dso_local noundef <2 x double> @_Z12muladd_test5Dv2_dS_S_(<2 x double> noundef %a, <2 x double> noundef %b, <2 x double> noundef %c) local_unnamed_addr #2 { +entry: + %mul = fmul <2 x double> %a, %b + %add = fadd <2 x double> %a, %b + %sub = fsub <2 x double> %add, %c + %add1 = fadd <2 x double> %mul, %c + %add2 = fadd <2 x double> %add1, %sub + ret <2 x double> %add2 +} + +; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(none) uwtable +define dso_local noundef <2 x double> @_Z12muladd_test6Dv2_dS_S_(<2 x double> noundef %a, <2 x double> noundef %b, <2 x double> noundef %c) local_unnamed_addr #2 { +entry: + %mul = fmul <2 x double> %a, %b + %mul1 = fmul <2 x double> %mul, %c + ret <2 x double> %mul1 +} + +attributes #0 = { mustprogress nofree nosync nounwind willreturn memory(none) uwtable "min-legal-vector-width"="128" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" } +attributes #1 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) } +attributes #2 = { mustprogress nofree norecurse nosync nounwind willreturn memory(none) uwtable "min-legal-vector-width"="128" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" } + +!llvm.module.flags = !{!0, !1, !2, !3} +!llvm.ident = !{!4} + +!0 = !{i32 1, !"wchar_size", i32 4} +!1 = !{i32 8, !"PIC Level", i32 2} +!2 = !{i32 7, !"PIE Level", i32 2} +!3 = !{i32 7, !"uwtable", i32 2} +!4 = !{!"clang version 17.0.6 (https://github.com/Kuznetsov-Artyom/llvm-nnsu-2024 d0378b668d4e9e7b60a19069049f55c257d8a3bf)"} diff --git a/llvm/test/lab3/kuznetsov_artyom/test.mir b/llvm/test/lab3/kuznetsov_artyom/test.mir new file mode 100644 index 0000000000000..f6fe91b77014c --- /dev/null +++ b/llvm/test/lab3/kuznetsov_artyom/test.mir @@ -0,0 +1,447 @@ +--- | + ; ModuleID = 'test.ll' + source_filename = "test.cpp" + target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" + target triple = "x86_64-unknown-linux-gnu" + + ; Function Attrs: mustprogress nofree nosync nounwind willreturn memory(none) uwtable + define dso_local noundef <2 x double> @_Z12muladd_test1Dv2_dS_S_(<2 x double> noundef %a, <2 x double> noundef %b, <2 x double> noundef %c) local_unnamed_addr #0 { + entry: + %0 = tail call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %a, <2 x double> %b, <2 x double> %c) + ret <2 x double> %0 + } + + ; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none) + declare <2 x double> @llvm.fmuladd.v2f64(<2 x double>, <2 x double>, <2 x double>) #1 + + ; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(none) uwtable + define dso_local noundef <2 x double> @_Z12muladd_test2Dv2_dS_S_(<2 x double> noundef %a, <2 x double> noundef %b, <2 x double> noundef %c) local_unnamed_addr #2 { + entry: + %mul = fmul <2 x double> %a, %b + %add = fadd <2 x double> %mul, %c + ret <2 x double> %add + } + + ; Function Attrs: mustprogress nofree nosync nounwind willreturn memory(none) uwtable + define dso_local noundef <2 x double> @_Z12muladd_test3Dv2_dS_S_(<2 x double> noundef %a, <2 x double> noundef %b, <2 x double> noundef %c) local_unnamed_addr #0 { + entry: + %0 = tail call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %a, <2 x double> %c, <2 x double> %b) + %1 = tail call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %0, <2 x double> %c, <2 x double> %b) + ret <2 x double> %1 + } + + ; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(none) uwtable + define dso_local noundef <2 x double> @_Z12muladd_test4Dv2_dS_S_(<2 x double> noundef %a, <2 x double> noundef %b, <2 x double> noundef %c) local_unnamed_addr #2 { + entry: + %mul = fmul <2 x double> %a, %c + %div = fdiv <2 x double> %mul, %b + %add = fadd <2 x double> %div, %b + ret <2 x double> %add + } + + ; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(none) uwtable + define dso_local noundef <2 x double> @_Z12muladd_test5Dv2_dS_S_(<2 x double> noundef %a, <2 x double> noundef %b, <2 x double> noundef %c) local_unnamed_addr #2 { + entry: + %mul = fmul <2 x double> %a, %b + %add = fadd <2 x double> %a, %b + %sub = fsub <2 x double> %add, %c + %add1 = fadd <2 x double> %mul, %c + %add2 = fadd <2 x double> %add1, %sub + ret <2 x double> %add2 + } + + ; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(none) uwtable + define dso_local noundef <2 x double> @_Z12muladd_test6Dv2_dS_S_(<2 x double> noundef %a, <2 x double> noundef %b, <2 x double> noundef %c) local_unnamed_addr #2 { + entry: + %mul = fmul <2 x double> %a, %b + %mul1 = fmul <2 x double> %mul, %c + ret <2 x double> %mul1 + } + + attributes #0 = { mustprogress nofree nosync nounwind willreturn memory(none) uwtable "min-legal-vector-width"="128" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" } + attributes #1 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) } + attributes #2 = { mustprogress nofree norecurse nosync nounwind willreturn memory(none) uwtable "min-legal-vector-width"="128" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" } + + !llvm.module.flags = !{!0, !1, !2, !3} + !llvm.ident = !{!4} + + !0 = !{i32 1, !"wchar_size", i32 4} + !1 = !{i32 8, !"PIC Level", i32 2} + !2 = !{i32 7, !"PIE Level", i32 2} + !3 = !{i32 7, !"uwtable", i32 2} + !4 = !{!"clang version 17.0.6 (https://github.com/Kuznetsov-Artyom/llvm-nnsu-2024 d0378b668d4e9e7b60a19069049f55c257d8a3bf)"} + +... +--- +name: _Z12muladd_test1Dv2_dS_S_ +alignment: 16 +exposesReturnsTwice: false +legalized: false +regBankSelected: false +selected: false +failedISel: false +tracksRegLiveness: true +hasWinCFI: false +callsEHReturn: false +callsUnwindInit: false +hasEHCatchret: false +hasEHScopes: false +hasEHFunclets: false +isOutlined: false +debugInstrRef: true +failsVerification: false +tracksDebugUserValues: true +registers: [] +liveins: + - { reg: '$xmm0', virtual-reg: '' } + - { reg: '$xmm1', virtual-reg: '' } + - { reg: '$xmm2', virtual-reg: '' } +frameInfo: + isFrameAddressTaken: false + isReturnAddressTaken: false + hasStackMap: false + hasPatchPoint: false + stackSize: 0 + offsetAdjustment: 0 + maxAlignment: 1 + adjustsStack: false + hasCalls: false + stackProtector: '' + functionContext: '' + maxCallFrameSize: 0 + cvBytesOfCalleeSavedRegisters: 0 + hasOpaqueSPAdjustment: false + hasVAStart: false + hasMustTailInVarArgFunc: false + hasTailCall: false + localFrameSize: 0 + savePoint: '' + restorePoint: '' +fixedStack: [] +stack: [] +entry_values: [] +callSites: [] +debugValueSubstitutions: [] +constants: [] +machineFunctionInfo: {} +body: | + bb.0.entry: + liveins: $xmm0, $xmm1, $xmm2 + + renamable $xmm0 = nofpexcept MULPDrr killed renamable $xmm0, killed renamable $xmm1, implicit $mxcsr + renamable $xmm0 = nofpexcept ADDPDrr killed renamable $xmm0, killed renamable $xmm2, implicit $mxcsr + RET64 $xmm0 + +... +--- +name: _Z12muladd_test2Dv2_dS_S_ +alignment: 16 +exposesReturnsTwice: false +legalized: false +regBankSelected: false +selected: false +failedISel: false +tracksRegLiveness: true +hasWinCFI: false +callsEHReturn: false +callsUnwindInit: false +hasEHCatchret: false +hasEHScopes: false +hasEHFunclets: false +isOutlined: false +debugInstrRef: true +failsVerification: false +tracksDebugUserValues: true +registers: [] +liveins: + - { reg: '$xmm0', virtual-reg: '' } + - { reg: '$xmm1', virtual-reg: '' } + - { reg: '$xmm2', virtual-reg: '' } +frameInfo: + isFrameAddressTaken: false + isReturnAddressTaken: false + hasStackMap: false + hasPatchPoint: false + stackSize: 0 + offsetAdjustment: 0 + maxAlignment: 1 + adjustsStack: false + hasCalls: false + stackProtector: '' + functionContext: '' + maxCallFrameSize: 0 + cvBytesOfCalleeSavedRegisters: 0 + hasOpaqueSPAdjustment: false + hasVAStart: false + hasMustTailInVarArgFunc: false + hasTailCall: false + localFrameSize: 0 + savePoint: '' + restorePoint: '' +fixedStack: [] +stack: [] +entry_values: [] +callSites: [] +debugValueSubstitutions: [] +constants: [] +machineFunctionInfo: {} +body: | + bb.0.entry: + liveins: $xmm0, $xmm1, $xmm2 + + renamable $xmm0 = nofpexcept MULPDrr killed renamable $xmm0, killed renamable $xmm1, implicit $mxcsr + renamable $xmm0 = nofpexcept ADDPDrr killed renamable $xmm0, killed renamable $xmm2, implicit $mxcsr + RET64 $xmm0 + +... +--- +name: _Z12muladd_test3Dv2_dS_S_ +alignment: 16 +exposesReturnsTwice: false +legalized: false +regBankSelected: false +selected: false +failedISel: false +tracksRegLiveness: true +hasWinCFI: false +callsEHReturn: false +callsUnwindInit: false +hasEHCatchret: false +hasEHScopes: false +hasEHFunclets: false +isOutlined: false +debugInstrRef: true +failsVerification: false +tracksDebugUserValues: true +registers: [] +liveins: + - { reg: '$xmm0', virtual-reg: '' } + - { reg: '$xmm1', virtual-reg: '' } + - { reg: '$xmm2', virtual-reg: '' } +frameInfo: + isFrameAddressTaken: false + isReturnAddressTaken: false + hasStackMap: false + hasPatchPoint: false + stackSize: 0 + offsetAdjustment: 0 + maxAlignment: 1 + adjustsStack: false + hasCalls: false + stackProtector: '' + functionContext: '' + maxCallFrameSize: 0 + cvBytesOfCalleeSavedRegisters: 0 + hasOpaqueSPAdjustment: false + hasVAStart: false + hasMustTailInVarArgFunc: false + hasTailCall: false + localFrameSize: 0 + savePoint: '' + restorePoint: '' +fixedStack: [] +stack: [] +entry_values: [] +callSites: [] +debugValueSubstitutions: [] +constants: [] +machineFunctionInfo: {} +body: | + bb.0.entry: + liveins: $xmm0, $xmm1, $xmm2 + + renamable $xmm0 = nofpexcept MULPDrr killed renamable $xmm0, renamable $xmm2, implicit $mxcsr + renamable $xmm0 = nofpexcept ADDPDrr killed renamable $xmm0, renamable $xmm1, implicit $mxcsr + renamable $xmm0 = nofpexcept MULPDrr killed renamable $xmm0, killed renamable $xmm2, implicit $mxcsr + renamable $xmm0 = nofpexcept ADDPDrr killed renamable $xmm0, killed renamable $xmm1, implicit $mxcsr + RET64 $xmm0 + +... +--- +name: _Z12muladd_test4Dv2_dS_S_ +alignment: 16 +exposesReturnsTwice: false +legalized: false +regBankSelected: false +selected: false +failedISel: false +tracksRegLiveness: true +hasWinCFI: false +callsEHReturn: false +callsUnwindInit: false +hasEHCatchret: false +hasEHScopes: false +hasEHFunclets: false +isOutlined: false +debugInstrRef: true +failsVerification: false +tracksDebugUserValues: true +registers: [] +liveins: + - { reg: '$xmm0', virtual-reg: '' } + - { reg: '$xmm1', virtual-reg: '' } + - { reg: '$xmm2', virtual-reg: '' } +frameInfo: + isFrameAddressTaken: false + isReturnAddressTaken: false + hasStackMap: false + hasPatchPoint: false + stackSize: 0 + offsetAdjustment: 0 + maxAlignment: 1 + adjustsStack: false + hasCalls: false + stackProtector: '' + functionContext: '' + maxCallFrameSize: 0 + cvBytesOfCalleeSavedRegisters: 0 + hasOpaqueSPAdjustment: false + hasVAStart: false + hasMustTailInVarArgFunc: false + hasTailCall: false + localFrameSize: 0 + savePoint: '' + restorePoint: '' +fixedStack: [] +stack: [] +entry_values: [] +callSites: [] +debugValueSubstitutions: [] +constants: [] +machineFunctionInfo: {} +body: | + bb.0.entry: + liveins: $xmm0, $xmm1, $xmm2 + + renamable $xmm0 = nofpexcept MULPDrr killed renamable $xmm0, killed renamable $xmm2, implicit $mxcsr + renamable $xmm0 = nofpexcept DIVPDrr killed renamable $xmm0, renamable $xmm1, implicit $mxcsr + renamable $xmm0 = nofpexcept ADDPDrr killed renamable $xmm0, killed renamable $xmm1, implicit $mxcsr + RET64 $xmm0 + +... +--- +name: _Z12muladd_test5Dv2_dS_S_ +alignment: 16 +exposesReturnsTwice: false +legalized: false +regBankSelected: false +selected: false +failedISel: false +tracksRegLiveness: true +hasWinCFI: false +callsEHReturn: false +callsUnwindInit: false +hasEHCatchret: false +hasEHScopes: false +hasEHFunclets: false +isOutlined: false +debugInstrRef: true +failsVerification: false +tracksDebugUserValues: true +registers: [] +liveins: + - { reg: '$xmm0', virtual-reg: '' } + - { reg: '$xmm1', virtual-reg: '' } + - { reg: '$xmm2', virtual-reg: '' } +frameInfo: + isFrameAddressTaken: false + isReturnAddressTaken: false + hasStackMap: false + hasPatchPoint: false + stackSize: 0 + offsetAdjustment: 0 + maxAlignment: 1 + adjustsStack: false + hasCalls: false + stackProtector: '' + functionContext: '' + maxCallFrameSize: 0 + cvBytesOfCalleeSavedRegisters: 0 + hasOpaqueSPAdjustment: false + hasVAStart: false + hasMustTailInVarArgFunc: false + hasTailCall: false + localFrameSize: 0 + savePoint: '' + restorePoint: '' +fixedStack: [] +stack: [] +entry_values: [] +callSites: [] +debugValueSubstitutions: [] +constants: [] +machineFunctionInfo: {} +body: | + bb.0.entry: + liveins: $xmm0, $xmm1, $xmm2 + + $xmm3 = MOVAPDrr $xmm0 + renamable $xmm3 = nofpexcept MULPDrr killed renamable $xmm3, renamable $xmm1, implicit $mxcsr + renamable $xmm0 = nofpexcept ADDPDrr killed renamable $xmm0, killed renamable $xmm1, implicit $mxcsr + renamable $xmm0 = nofpexcept SUBPDrr killed renamable $xmm0, renamable $xmm2, implicit $mxcsr + renamable $xmm3 = nofpexcept ADDPDrr killed renamable $xmm3, killed renamable $xmm2, implicit $mxcsr + renamable $xmm0 = nofpexcept ADDPDrr killed renamable $xmm0, killed renamable $xmm3, implicit $mxcsr + RET64 $xmm0 + +... +--- +name: _Z12muladd_test6Dv2_dS_S_ +alignment: 16 +exposesReturnsTwice: false +legalized: false +regBankSelected: false +selected: false +failedISel: false +tracksRegLiveness: true +hasWinCFI: false +callsEHReturn: false +callsUnwindInit: false +hasEHCatchret: false +hasEHScopes: false +hasEHFunclets: false +isOutlined: false +debugInstrRef: true +failsVerification: false +tracksDebugUserValues: true +registers: [] +liveins: + - { reg: '$xmm0', virtual-reg: '' } + - { reg: '$xmm1', virtual-reg: '' } + - { reg: '$xmm2', virtual-reg: '' } +frameInfo: + isFrameAddressTaken: false + isReturnAddressTaken: false + hasStackMap: false + hasPatchPoint: false + stackSize: 0 + offsetAdjustment: 0 + maxAlignment: 1 + adjustsStack: false + hasCalls: false + stackProtector: '' + functionContext: '' + maxCallFrameSize: 0 + cvBytesOfCalleeSavedRegisters: 0 + hasOpaqueSPAdjustment: false + hasVAStart: false + hasMustTailInVarArgFunc: false + hasTailCall: false + localFrameSize: 0 + savePoint: '' + restorePoint: '' +fixedStack: [] +stack: [] +entry_values: [] +callSites: [] +debugValueSubstitutions: [] +constants: [] +machineFunctionInfo: {} +body: | + bb.0.entry: + liveins: $xmm0, $xmm1, $xmm2 + + renamable $xmm0 = nofpexcept MULPDrr killed renamable $xmm0, killed renamable $xmm1, implicit $mxcsr + renamable $xmm0 = nofpexcept MULPDrr killed renamable $xmm0, killed renamable $xmm2, implicit $mxcsr + RET64 $xmm0 + +... diff --git a/llvm/test/lab3/kuznetsov_artyom/test_out.mir b/llvm/test/lab3/kuznetsov_artyom/test_out.mir new file mode 100644 index 0000000000000..20ae06a505e72 --- /dev/null +++ b/llvm/test/lab3/kuznetsov_artyom/test_out.mir @@ -0,0 +1,442 @@ +--- | + ; ModuleID = 'test.mir' + source_filename = "test.cpp" + target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" + target triple = "x86_64-unknown-linux-gnu" + + ; Function Attrs: mustprogress nofree nosync nounwind willreturn memory(none) uwtable + define dso_local noundef <2 x double> @_Z12muladd_test1Dv2_dS_S_(<2 x double> noundef %a, <2 x double> noundef %b, <2 x double> noundef %c) local_unnamed_addr #0 { + entry: + %0 = tail call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %a, <2 x double> %b, <2 x double> %c) + ret <2 x double> %0 + } + + ; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none) + declare <2 x double> @llvm.fmuladd.v2f64(<2 x double>, <2 x double>, <2 x double>) #1 + + ; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(none) uwtable + define dso_local noundef <2 x double> @_Z12muladd_test2Dv2_dS_S_(<2 x double> noundef %a, <2 x double> noundef %b, <2 x double> noundef %c) local_unnamed_addr #2 { + entry: + %mul = fmul <2 x double> %a, %b + %add = fadd <2 x double> %mul, %c + ret <2 x double> %add + } + + ; Function Attrs: mustprogress nofree nosync nounwind willreturn memory(none) uwtable + define dso_local noundef <2 x double> @_Z12muladd_test3Dv2_dS_S_(<2 x double> noundef %a, <2 x double> noundef %b, <2 x double> noundef %c) local_unnamed_addr #0 { + entry: + %0 = tail call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %a, <2 x double> %c, <2 x double> %b) + %1 = tail call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %0, <2 x double> %c, <2 x double> %b) + ret <2 x double> %1 + } + + ; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(none) uwtable + define dso_local noundef <2 x double> @_Z12muladd_test4Dv2_dS_S_(<2 x double> noundef %a, <2 x double> noundef %b, <2 x double> noundef %c) local_unnamed_addr #2 { + entry: + %mul = fmul <2 x double> %a, %c + %div = fdiv <2 x double> %mul, %b + %add = fadd <2 x double> %div, %b + ret <2 x double> %add + } + + ; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(none) uwtable + define dso_local noundef <2 x double> @_Z12muladd_test5Dv2_dS_S_(<2 x double> noundef %a, <2 x double> noundef %b, <2 x double> noundef %c) local_unnamed_addr #2 { + entry: + %mul = fmul <2 x double> %a, %b + %add = fadd <2 x double> %a, %b + %sub = fsub <2 x double> %add, %c + %add1 = fadd <2 x double> %mul, %c + %add2 = fadd <2 x double> %add1, %sub + ret <2 x double> %add2 + } + + ; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(none) uwtable + define dso_local noundef <2 x double> @_Z12muladd_test6Dv2_dS_S_(<2 x double> noundef %a, <2 x double> noundef %b, <2 x double> noundef %c) local_unnamed_addr #2 { + entry: + %mul = fmul <2 x double> %a, %b + %mul1 = fmul <2 x double> %mul, %c + ret <2 x double> %mul1 + } + + attributes #0 = { mustprogress nofree nosync nounwind willreturn memory(none) uwtable "min-legal-vector-width"="128" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" } + attributes #1 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) } + attributes #2 = { mustprogress nofree norecurse nosync nounwind willreturn memory(none) uwtable "min-legal-vector-width"="128" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" } + + !llvm.module.flags = !{!0, !1, !2, !3} + !llvm.ident = !{!4} + + !0 = !{i32 1, !"wchar_size", i32 4} + !1 = !{i32 8, !"PIC Level", i32 2} + !2 = !{i32 7, !"PIE Level", i32 2} + !3 = !{i32 7, !"uwtable", i32 2} + !4 = !{!"clang version 17.0.6 (https://github.com/Kuznetsov-Artyom/llvm-nnsu-2024 d0378b668d4e9e7b60a19069049f55c257d8a3bf)"} + +... +--- +name: _Z12muladd_test1Dv2_dS_S_ +alignment: 16 +exposesReturnsTwice: false +legalized: false +regBankSelected: false +selected: false +failedISel: false +tracksRegLiveness: true +hasWinCFI: false +callsEHReturn: false +callsUnwindInit: false +hasEHCatchret: false +hasEHScopes: false +hasEHFunclets: false +isOutlined: false +debugInstrRef: true +failsVerification: false +tracksDebugUserValues: true +registers: [] +liveins: + - { reg: '$xmm0', virtual-reg: '' } + - { reg: '$xmm1', virtual-reg: '' } + - { reg: '$xmm2', virtual-reg: '' } +frameInfo: + isFrameAddressTaken: false + isReturnAddressTaken: false + hasStackMap: false + hasPatchPoint: false + stackSize: 0 + offsetAdjustment: 0 + maxAlignment: 1 + adjustsStack: false + hasCalls: false + stackProtector: '' + functionContext: '' + maxCallFrameSize: 0 + cvBytesOfCalleeSavedRegisters: 0 + hasOpaqueSPAdjustment: false + hasVAStart: false + hasMustTailInVarArgFunc: false + hasTailCall: false + localFrameSize: 0 + savePoint: '' + restorePoint: '' +fixedStack: [] +stack: [] +entry_values: [] +callSites: [] +debugValueSubstitutions: [] +constants: [] +machineFunctionInfo: {} +body: | + bb.0.entry: + liveins: $xmm0, $xmm1, $xmm2 + + $xmm0 = VFMADD213PDZ128r $xmm0, $xmm1, $xmm2, implicit $mxcsr + RET64 $xmm0 + +... +--- +name: _Z12muladd_test2Dv2_dS_S_ +alignment: 16 +exposesReturnsTwice: false +legalized: false +regBankSelected: false +selected: false +failedISel: false +tracksRegLiveness: true +hasWinCFI: false +callsEHReturn: false +callsUnwindInit: false +hasEHCatchret: false +hasEHScopes: false +hasEHFunclets: false +isOutlined: false +debugInstrRef: true +failsVerification: false +tracksDebugUserValues: true +registers: [] +liveins: + - { reg: '$xmm0', virtual-reg: '' } + - { reg: '$xmm1', virtual-reg: '' } + - { reg: '$xmm2', virtual-reg: '' } +frameInfo: + isFrameAddressTaken: false + isReturnAddressTaken: false + hasStackMap: false + hasPatchPoint: false + stackSize: 0 + offsetAdjustment: 0 + maxAlignment: 1 + adjustsStack: false + hasCalls: false + stackProtector: '' + functionContext: '' + maxCallFrameSize: 0 + cvBytesOfCalleeSavedRegisters: 0 + hasOpaqueSPAdjustment: false + hasVAStart: false + hasMustTailInVarArgFunc: false + hasTailCall: false + localFrameSize: 0 + savePoint: '' + restorePoint: '' +fixedStack: [] +stack: [] +entry_values: [] +callSites: [] +debugValueSubstitutions: [] +constants: [] +machineFunctionInfo: {} +body: | + bb.0.entry: + liveins: $xmm0, $xmm1, $xmm2 + + $xmm0 = VFMADD213PDZ128r $xmm0, $xmm1, $xmm2, implicit $mxcsr + RET64 $xmm0 + +... +--- +name: _Z12muladd_test3Dv2_dS_S_ +alignment: 16 +exposesReturnsTwice: false +legalized: false +regBankSelected: false +selected: false +failedISel: false +tracksRegLiveness: true +hasWinCFI: false +callsEHReturn: false +callsUnwindInit: false +hasEHCatchret: false +hasEHScopes: false +hasEHFunclets: false +isOutlined: false +debugInstrRef: true +failsVerification: false +tracksDebugUserValues: true +registers: [] +liveins: + - { reg: '$xmm0', virtual-reg: '' } + - { reg: '$xmm1', virtual-reg: '' } + - { reg: '$xmm2', virtual-reg: '' } +frameInfo: + isFrameAddressTaken: false + isReturnAddressTaken: false + hasStackMap: false + hasPatchPoint: false + stackSize: 0 + offsetAdjustment: 0 + maxAlignment: 1 + adjustsStack: false + hasCalls: false + stackProtector: '' + functionContext: '' + maxCallFrameSize: 0 + cvBytesOfCalleeSavedRegisters: 0 + hasOpaqueSPAdjustment: false + hasVAStart: false + hasMustTailInVarArgFunc: false + hasTailCall: false + localFrameSize: 0 + savePoint: '' + restorePoint: '' +fixedStack: [] +stack: [] +entry_values: [] +callSites: [] +debugValueSubstitutions: [] +constants: [] +machineFunctionInfo: {} +body: | + bb.0.entry: + liveins: $xmm0, $xmm1, $xmm2 + + $xmm0 = VFMADD213PDZ128r $xmm0, $xmm2, $xmm1, implicit $mxcsr + $xmm0 = VFMADD213PDZ128r $xmm0, $xmm2, $xmm1, implicit $mxcsr + RET64 $xmm0 + +... +--- +name: _Z12muladd_test4Dv2_dS_S_ +alignment: 16 +exposesReturnsTwice: false +legalized: false +regBankSelected: false +selected: false +failedISel: false +tracksRegLiveness: true +hasWinCFI: false +callsEHReturn: false +callsUnwindInit: false +hasEHCatchret: false +hasEHScopes: false +hasEHFunclets: false +isOutlined: false +debugInstrRef: true +failsVerification: false +tracksDebugUserValues: true +registers: [] +liveins: + - { reg: '$xmm0', virtual-reg: '' } + - { reg: '$xmm1', virtual-reg: '' } + - { reg: '$xmm2', virtual-reg: '' } +frameInfo: + isFrameAddressTaken: false + isReturnAddressTaken: false + hasStackMap: false + hasPatchPoint: false + stackSize: 0 + offsetAdjustment: 0 + maxAlignment: 1 + adjustsStack: false + hasCalls: false + stackProtector: '' + functionContext: '' + maxCallFrameSize: 0 + cvBytesOfCalleeSavedRegisters: 0 + hasOpaqueSPAdjustment: false + hasVAStart: false + hasMustTailInVarArgFunc: false + hasTailCall: false + localFrameSize: 0 + savePoint: '' + restorePoint: '' +fixedStack: [] +stack: [] +entry_values: [] +callSites: [] +debugValueSubstitutions: [] +constants: [] +machineFunctionInfo: {} +body: | + bb.0.entry: + liveins: $xmm0, $xmm1, $xmm2 + + renamable $xmm0 = nofpexcept MULPDrr killed renamable $xmm0, killed renamable $xmm2, implicit $mxcsr + renamable $xmm0 = nofpexcept DIVPDrr killed renamable $xmm0, renamable $xmm1, implicit $mxcsr + renamable $xmm0 = nofpexcept ADDPDrr killed renamable $xmm0, killed renamable $xmm1, implicit $mxcsr + RET64 $xmm0 + +... +--- +name: _Z12muladd_test5Dv2_dS_S_ +alignment: 16 +exposesReturnsTwice: false +legalized: false +regBankSelected: false +selected: false +failedISel: false +tracksRegLiveness: true +hasWinCFI: false +callsEHReturn: false +callsUnwindInit: false +hasEHCatchret: false +hasEHScopes: false +hasEHFunclets: false +isOutlined: false +debugInstrRef: true +failsVerification: false +tracksDebugUserValues: true +registers: [] +liveins: + - { reg: '$xmm0', virtual-reg: '' } + - { reg: '$xmm1', virtual-reg: '' } + - { reg: '$xmm2', virtual-reg: '' } +frameInfo: + isFrameAddressTaken: false + isReturnAddressTaken: false + hasStackMap: false + hasPatchPoint: false + stackSize: 0 + offsetAdjustment: 0 + maxAlignment: 1 + adjustsStack: false + hasCalls: false + stackProtector: '' + functionContext: '' + maxCallFrameSize: 0 + cvBytesOfCalleeSavedRegisters: 0 + hasOpaqueSPAdjustment: false + hasVAStart: false + hasMustTailInVarArgFunc: false + hasTailCall: false + localFrameSize: 0 + savePoint: '' + restorePoint: '' +fixedStack: [] +stack: [] +entry_values: [] +callSites: [] +debugValueSubstitutions: [] +constants: [] +machineFunctionInfo: {} +body: | + bb.0.entry: + liveins: $xmm0, $xmm1, $xmm2 + + $xmm3 = MOVAPDrr $xmm0 + $xmm3 = VFMADD213PDZ128r $xmm3, $xmm1, $xmm2, implicit $mxcsr + renamable $xmm0 = nofpexcept ADDPDrr killed renamable $xmm0, killed renamable $xmm1, implicit $mxcsr + renamable $xmm0 = nofpexcept SUBPDrr killed renamable $xmm0, renamable $xmm2, implicit $mxcsr + renamable $xmm0 = nofpexcept ADDPDrr killed renamable $xmm0, killed renamable $xmm3, implicit $mxcsr + RET64 $xmm0 + +... +--- +name: _Z12muladd_test6Dv2_dS_S_ +alignment: 16 +exposesReturnsTwice: false +legalized: false +regBankSelected: false +selected: false +failedISel: false +tracksRegLiveness: true +hasWinCFI: false +callsEHReturn: false +callsUnwindInit: false +hasEHCatchret: false +hasEHScopes: false +hasEHFunclets: false +isOutlined: false +debugInstrRef: true +failsVerification: false +tracksDebugUserValues: true +registers: [] +liveins: + - { reg: '$xmm0', virtual-reg: '' } + - { reg: '$xmm1', virtual-reg: '' } + - { reg: '$xmm2', virtual-reg: '' } +frameInfo: + isFrameAddressTaken: false + isReturnAddressTaken: false + hasStackMap: false + hasPatchPoint: false + stackSize: 0 + offsetAdjustment: 0 + maxAlignment: 1 + adjustsStack: false + hasCalls: false + stackProtector: '' + functionContext: '' + maxCallFrameSize: 0 + cvBytesOfCalleeSavedRegisters: 0 + hasOpaqueSPAdjustment: false + hasVAStart: false + hasMustTailInVarArgFunc: false + hasTailCall: false + localFrameSize: 0 + savePoint: '' + restorePoint: '' +fixedStack: [] +stack: [] +entry_values: [] +callSites: [] +debugValueSubstitutions: [] +constants: [] +machineFunctionInfo: {} +body: | + bb.0.entry: + liveins: $xmm0, $xmm1, $xmm2 + + renamable $xmm0 = nofpexcept MULPDrr killed renamable $xmm0, killed renamable $xmm1, implicit $mxcsr + renamable $xmm0 = nofpexcept MULPDrr killed renamable $xmm0, killed renamable $xmm2, implicit $mxcsr + RET64 $xmm0 + +... From 8f24c245f5d942a6bd6eb393f4c8900ce61c08cb Mon Sep 17 00:00:00 2001 From: Kuznetsov-Artyom Date: Tue, 23 Apr 2024 03:22:49 +0300 Subject: [PATCH 07/10] add new tests --- llvm/test/lab3/kuznetsov_artyom/test.cpp | 30 -- llvm/test/lab3/kuznetsov_artyom/test.ll | 71 --- llvm/test/lab3/kuznetsov_artyom/test.mir | 98 ++++ llvm/test/lab3/kuznetsov_artyom/test_out.mir | 442 ------------------- llvm/test/lab3/kuznetsov_artyom/testing.mir | 285 ------------ 5 files changed, 98 insertions(+), 828 deletions(-) delete mode 100644 llvm/test/lab3/kuznetsov_artyom/test.cpp delete mode 100644 llvm/test/lab3/kuznetsov_artyom/test.ll delete mode 100644 llvm/test/lab3/kuznetsov_artyom/test_out.mir delete mode 100644 llvm/test/lab3/kuznetsov_artyom/testing.mir diff --git a/llvm/test/lab3/kuznetsov_artyom/test.cpp b/llvm/test/lab3/kuznetsov_artyom/test.cpp deleted file mode 100644 index a39e5ac13d3b7..0000000000000 --- a/llvm/test/lab3/kuznetsov_artyom/test.cpp +++ /dev/null @@ -1,30 +0,0 @@ -#include - -__m128d muladd_test1(__m128d a, __m128d b, __m128d c) { return a * b + c; } // + - -__m128d muladd_test2(__m128d a, __m128d b, __m128d c) { // + - __m128d tmp = a * b; - tmp = tmp + c; - return tmp; -} - -__m128d muladd_test3(__m128d a, __m128d b, __m128d c) { // + - __m128d tmp = a * c + b; - return tmp * c + b; -} - -__m128d muladd_test4(__m128d a, __m128d b, __m128d c) { // - - __m128d tmp = a * c; - tmp = tmp / b; - return tmp + b; -} -__m128d muladd_test5(__m128d a, __m128d b, __m128d c) { - __m128d tmp = a * b; - __m128d tmp2 = b + a - c; - return tmp + c + tmp2; -} -__m128d muladd_test6(__m128d a, __m128d b, __m128d c) { - __m128d tmp = a * b; - __m128d tmp2 = tmp + c; - return tmp * c; -} diff --git a/llvm/test/lab3/kuznetsov_artyom/test.ll b/llvm/test/lab3/kuznetsov_artyom/test.ll deleted file mode 100644 index 03f95814823fe..0000000000000 --- a/llvm/test/lab3/kuznetsov_artyom/test.ll +++ /dev/null @@ -1,71 +0,0 @@ -; ModuleID = 'test.cpp' -source_filename = "test.cpp" -target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" -target triple = "x86_64-unknown-linux-gnu" - -; Function Attrs: mustprogress nofree nosync nounwind willreturn memory(none) uwtable -define dso_local noundef <2 x double> @_Z12muladd_test1Dv2_dS_S_(<2 x double> noundef %a, <2 x double> noundef %b, <2 x double> noundef %c) local_unnamed_addr #0 { -entry: - %0 = tail call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %a, <2 x double> %b, <2 x double> %c) - ret <2 x double> %0 -} - -; Function Attrs: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) -declare <2 x double> @llvm.fmuladd.v2f64(<2 x double>, <2 x double>, <2 x double>) #1 - -; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(none) uwtable -define dso_local noundef <2 x double> @_Z12muladd_test2Dv2_dS_S_(<2 x double> noundef %a, <2 x double> noundef %b, <2 x double> noundef %c) local_unnamed_addr #2 { -entry: - %mul = fmul <2 x double> %a, %b - %add = fadd <2 x double> %mul, %c - ret <2 x double> %add -} - -; Function Attrs: mustprogress nofree nosync nounwind willreturn memory(none) uwtable -define dso_local noundef <2 x double> @_Z12muladd_test3Dv2_dS_S_(<2 x double> noundef %a, <2 x double> noundef %b, <2 x double> noundef %c) local_unnamed_addr #0 { -entry: - %0 = tail call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %a, <2 x double> %c, <2 x double> %b) - %1 = tail call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %0, <2 x double> %c, <2 x double> %b) - ret <2 x double> %1 -} - -; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(none) uwtable -define dso_local noundef <2 x double> @_Z12muladd_test4Dv2_dS_S_(<2 x double> noundef %a, <2 x double> noundef %b, <2 x double> noundef %c) local_unnamed_addr #2 { -entry: - %mul = fmul <2 x double> %a, %c - %div = fdiv <2 x double> %mul, %b - %add = fadd <2 x double> %div, %b - ret <2 x double> %add -} - -; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(none) uwtable -define dso_local noundef <2 x double> @_Z12muladd_test5Dv2_dS_S_(<2 x double> noundef %a, <2 x double> noundef %b, <2 x double> noundef %c) local_unnamed_addr #2 { -entry: - %mul = fmul <2 x double> %a, %b - %add = fadd <2 x double> %a, %b - %sub = fsub <2 x double> %add, %c - %add1 = fadd <2 x double> %mul, %c - %add2 = fadd <2 x double> %add1, %sub - ret <2 x double> %add2 -} - -; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(none) uwtable -define dso_local noundef <2 x double> @_Z12muladd_test6Dv2_dS_S_(<2 x double> noundef %a, <2 x double> noundef %b, <2 x double> noundef %c) local_unnamed_addr #2 { -entry: - %mul = fmul <2 x double> %a, %b - %mul1 = fmul <2 x double> %mul, %c - ret <2 x double> %mul1 -} - -attributes #0 = { mustprogress nofree nosync nounwind willreturn memory(none) uwtable "min-legal-vector-width"="128" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" } -attributes #1 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) } -attributes #2 = { mustprogress nofree norecurse nosync nounwind willreturn memory(none) uwtable "min-legal-vector-width"="128" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" } - -!llvm.module.flags = !{!0, !1, !2, !3} -!llvm.ident = !{!4} - -!0 = !{i32 1, !"wchar_size", i32 4} -!1 = !{i32 8, !"PIC Level", i32 2} -!2 = !{i32 7, !"PIE Level", i32 2} -!3 = !{i32 7, !"uwtable", i32 2} -!4 = !{!"clang version 17.0.6 (https://github.com/Kuznetsov-Artyom/llvm-nnsu-2024 d0378b668d4e9e7b60a19069049f55c257d8a3bf)"} diff --git a/llvm/test/lab3/kuznetsov_artyom/test.mir b/llvm/test/lab3/kuznetsov_artyom/test.mir index f6fe91b77014c..1daebdd7e44b0 100644 --- a/llvm/test/lab3/kuznetsov_artyom/test.mir +++ b/llvm/test/lab3/kuznetsov_artyom/test.mir @@ -1,3 +1,39 @@ +# RUN: llc -mtriple x86_64-unknown-linux-gnu -run-pass=x86-muladd %s -o - | FileCheck %s + +# test.cpp + +# __m128d muladd_test1(__m128d a, __m128d b, __m128d c) { return a * b + c; } + +# __m128d muladd_test2(__m128d a, __m128d b, __m128d c) { +# __m128d tmp = a * b; +# tmp = tmp + c; +# return tmp; +# } + +# __m128d muladd_test3(__m128d a, __m128d b, __m128d c) { +# __m128d tmp = a * c + b; +# return tmp * c + b; +# } + +# __m128d muladd_test4(__m128d a, __m128d b, __m128d c) { +# __m128d tmp = a * c; +# tmp = tmp / b; +# return tmp + b; +# } + +# __m128d muladd_test5(__m128d a, __m128d b, __m128d c) { +# __m128d tmp = a * b; +# __m128d tmp2 = b + a -c; +# return tmp + c + tmp2; +# } + +# __m128d muladd_test6(__m128d a, __m128d b, __m128d c) { +# __m128d tmp = a * b; +# __m128d tmp2 = tmp + c; +# return tmp * c; +# } + + --- | ; ModuleID = 'test.ll' source_filename = "test.cpp" @@ -132,6 +168,16 @@ body: | renamable $xmm0 = nofpexcept ADDPDrr killed renamable $xmm0, killed renamable $xmm2, implicit $mxcsr RET64 $xmm0 + ; CHECK: liveins: $xmm0, $xmm1, $xmm2 + + ; CHECK-NOT: renamable $xmm0 = nofpexcept MULPDrr killed renamable $xmm0, killed renamable $xmm1, implicit $mxcsr + ; CHECK-NOT: renamable $xmm0 = nofpexcept ADDPDrr killed renamable $xmm0, killed renamable $xmm2, implicit $mxcsr + ; CHECK: $xmm0 = VFMADD213PDZ128r $xmm0, $xmm1, $xmm2, implicit $mxcsr + ; CHECK-NOT: renamable $xmm0 = nofpexcept MULPDrr killed renamable $xmm0, killed renamable $xmm1, implicit $mxcsr + ; CHECK-NOT: renamable $xmm0 = nofpexcept ADDPDrr killed renamable $xmm0, killed renamable $xmm2, implicit $mxcsr + + ; CHECK-NEXT: RET64 $xmm0 + ... --- name: _Z12muladd_test2Dv2_dS_S_ @@ -193,6 +239,16 @@ body: | renamable $xmm0 = nofpexcept ADDPDrr killed renamable $xmm0, killed renamable $xmm2, implicit $mxcsr RET64 $xmm0 + ; CHECK: liveins: $xmm0, $xmm1, $xmm2 + + ; CHECK-NOT: renamable $xmm0 = nofpexcept MULPDrr killed renamable $xmm0, killed renamable $xmm1, implicit $mxcsr + ; CHECK-NOT: renamable $xmm0 = nofpexcept ADDPDrr killed renamable $xmm0, killed renamable $xmm2, implicit $mxcsr + ; CHECK: $xmm0 = VFMADD213PDZ128r $xmm0, $xmm1, $xmm2, implicit $mxcsr + ; CHECK-NOT: renamable $xmm0 = nofpexcept MULPDrr killed renamable $xmm0, killed renamable $xmm1, implicit $mxcsr + ; CHECK-NOT: renamable $xmm0 = nofpexcept ADDPDrr killed renamable $xmm0, killed renamable $xmm2, implicit $mxcsr + + ; CHECK-NEXT: RET64 $xmm0 + ... --- name: _Z12muladd_test3Dv2_dS_S_ @@ -256,6 +312,22 @@ body: | renamable $xmm0 = nofpexcept ADDPDrr killed renamable $xmm0, killed renamable $xmm1, implicit $mxcsr RET64 $xmm0 + ; CHECK: liveins: $xmm0, $xmm1, $xmm2 + + ; CHECK-NOT: renamable $xmm0 = nofpexcept MULPDrr killed renamable $xmm0, renamable $xmm2, implicit $mxcsr + ; CHECK-NOT: renamable $xmm0 = nofpexcept ADDPDrr killed renamable $xmm0, renamable $xmm1, implicit $mxcsr + ; CHECK: $xmm0 = VFMADD213PDZ128r $xmm0, $xmm2, $xmm1, implicit $mxcsr + ; CHECK-NOT: renamable $xmm0 = nofpexcept MULPDrr killed renamable $xmm0, renamable $xmm2, implicit $mxcsr + ; CHECK-NOT: renamable $xmm0 = nofpexcept ADDPDrr killed renamable $xmm0, renamable $xmm1, implicit $mxcsr + + ; CHECK-NOT: renamable $xmm0 = nofpexcept MULPDrr killed renamable $xmm0, killed renamable $xmm2, implicit $mxcsr + ; CHECK-NOT: renamable $xmm0 = nofpexcept ADDPDrr killed renamable $xmm0, killed renamable $xmm1, implicit $mxcsr + ; CHECK-NEXT: $xmm0 = VFMADD213PDZ128r $xmm0, $xmm2, $xmm1, implicit $mxcsr + ; CHECK-NOT: renamable $xmm0 = nofpexcept MULPDrr killed renamable $xmm0, renamable $xmm2, implicit $mxcsr + ; CHECK-NOT: renamable $xmm0 = nofpexcept ADDPDrr killed renamable $xmm0, renamable $xmm1, implicit $mxcsr + + ; CHECK-NEXT: RET64 $xmm0 + ... --- name: _Z12muladd_test4Dv2_dS_S_ @@ -318,6 +390,16 @@ body: | renamable $xmm0 = nofpexcept ADDPDrr killed renamable $xmm0, killed renamable $xmm1, implicit $mxcsr RET64 $xmm0 + ; CHECK: liveins: $xmm0, $xmm1, $xmm2 + + ; CHECK-NOT: $xmm0 = VFMADD213PDZ128r $xmm0, $xmm2, $xmm1, implicit $mxcsr + ; CHECK: renamable $xmm0 = nofpexcept MULPDrr killed renamable $xmm0, killed renamable $xmm2, implicit $mxcsr + ; CHECK-NOT: $xmm0 = VFMADD213PDZ128r $xmm0, $xmm2, $xmm1, implicit $mxcsr + + ; CHECK-NEXT: renamable $xmm0 = nofpexcept DIVPDrr killed renamable $xmm0, renamable $xmm1, implicit $mxcsr + ; CHECK-NEXT: renamable $xmm0 = nofpexcept ADDPDrr killed renamable $xmm0, killed renamable $xmm1, implicit $mxcsr + ; CHECK-NEXT: RET64 $xmm0 + ... --- name: _Z12muladd_test5Dv2_dS_S_ @@ -383,6 +465,16 @@ body: | renamable $xmm0 = nofpexcept ADDPDrr killed renamable $xmm0, killed renamable $xmm3, implicit $mxcsr RET64 $xmm0 + + ; CHECK: liveins: $xmm0, $xmm1, $xmm2 + + ; CHECK: $xmm3 = MOVAPDrr $xmm0 + ; CHECK-NEXT: $xmm3 = VFMADD213PDZ128r $xmm3, $xmm1, $xmm2, implicit $mxcsr + ; CHECK-NEXT: renamable $xmm0 = nofpexcept ADDPDrr killed renamable $xmm0, killed renamable $xmm1, implicit $mxcsr + ; CHECK-NEXT: renamable $xmm0 = nofpexcept SUBPDrr killed renamable $xmm0, renamable $xmm2, implicit $mxcsr + ; CHECK-NEXT: renamable $xmm0 = nofpexcept ADDPDrr killed renamable $xmm0, killed renamable $xmm3, implicit $mxcsr + ; CHECK-NEXT: RET64 $xmm0 + ... --- name: _Z12muladd_test6Dv2_dS_S_ @@ -444,4 +536,10 @@ body: | renamable $xmm0 = nofpexcept MULPDrr killed renamable $xmm0, killed renamable $xmm2, implicit $mxcsr RET64 $xmm0 + ; CHECK: liveins: $xmm0, $xmm1, $xmm2 + + ; CHECK: renamable $xmm0 = nofpexcept MULPDrr killed renamable $xmm0, killed renamable $xmm1, implicit $mxcsr + ; CHECK-NEXT: renamable $xmm0 = nofpexcept MULPDrr killed renamable $xmm0, killed renamable $xmm2, implicit $mxcsr + ; CHECK-NEXT: RET64 $xmm0 + ... diff --git a/llvm/test/lab3/kuznetsov_artyom/test_out.mir b/llvm/test/lab3/kuznetsov_artyom/test_out.mir deleted file mode 100644 index 20ae06a505e72..0000000000000 --- a/llvm/test/lab3/kuznetsov_artyom/test_out.mir +++ /dev/null @@ -1,442 +0,0 @@ ---- | - ; ModuleID = 'test.mir' - source_filename = "test.cpp" - target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" - target triple = "x86_64-unknown-linux-gnu" - - ; Function Attrs: mustprogress nofree nosync nounwind willreturn memory(none) uwtable - define dso_local noundef <2 x double> @_Z12muladd_test1Dv2_dS_S_(<2 x double> noundef %a, <2 x double> noundef %b, <2 x double> noundef %c) local_unnamed_addr #0 { - entry: - %0 = tail call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %a, <2 x double> %b, <2 x double> %c) - ret <2 x double> %0 - } - - ; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none) - declare <2 x double> @llvm.fmuladd.v2f64(<2 x double>, <2 x double>, <2 x double>) #1 - - ; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(none) uwtable - define dso_local noundef <2 x double> @_Z12muladd_test2Dv2_dS_S_(<2 x double> noundef %a, <2 x double> noundef %b, <2 x double> noundef %c) local_unnamed_addr #2 { - entry: - %mul = fmul <2 x double> %a, %b - %add = fadd <2 x double> %mul, %c - ret <2 x double> %add - } - - ; Function Attrs: mustprogress nofree nosync nounwind willreturn memory(none) uwtable - define dso_local noundef <2 x double> @_Z12muladd_test3Dv2_dS_S_(<2 x double> noundef %a, <2 x double> noundef %b, <2 x double> noundef %c) local_unnamed_addr #0 { - entry: - %0 = tail call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %a, <2 x double> %c, <2 x double> %b) - %1 = tail call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %0, <2 x double> %c, <2 x double> %b) - ret <2 x double> %1 - } - - ; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(none) uwtable - define dso_local noundef <2 x double> @_Z12muladd_test4Dv2_dS_S_(<2 x double> noundef %a, <2 x double> noundef %b, <2 x double> noundef %c) local_unnamed_addr #2 { - entry: - %mul = fmul <2 x double> %a, %c - %div = fdiv <2 x double> %mul, %b - %add = fadd <2 x double> %div, %b - ret <2 x double> %add - } - - ; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(none) uwtable - define dso_local noundef <2 x double> @_Z12muladd_test5Dv2_dS_S_(<2 x double> noundef %a, <2 x double> noundef %b, <2 x double> noundef %c) local_unnamed_addr #2 { - entry: - %mul = fmul <2 x double> %a, %b - %add = fadd <2 x double> %a, %b - %sub = fsub <2 x double> %add, %c - %add1 = fadd <2 x double> %mul, %c - %add2 = fadd <2 x double> %add1, %sub - ret <2 x double> %add2 - } - - ; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(none) uwtable - define dso_local noundef <2 x double> @_Z12muladd_test6Dv2_dS_S_(<2 x double> noundef %a, <2 x double> noundef %b, <2 x double> noundef %c) local_unnamed_addr #2 { - entry: - %mul = fmul <2 x double> %a, %b - %mul1 = fmul <2 x double> %mul, %c - ret <2 x double> %mul1 - } - - attributes #0 = { mustprogress nofree nosync nounwind willreturn memory(none) uwtable "min-legal-vector-width"="128" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" } - attributes #1 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) } - attributes #2 = { mustprogress nofree norecurse nosync nounwind willreturn memory(none) uwtable "min-legal-vector-width"="128" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" } - - !llvm.module.flags = !{!0, !1, !2, !3} - !llvm.ident = !{!4} - - !0 = !{i32 1, !"wchar_size", i32 4} - !1 = !{i32 8, !"PIC Level", i32 2} - !2 = !{i32 7, !"PIE Level", i32 2} - !3 = !{i32 7, !"uwtable", i32 2} - !4 = !{!"clang version 17.0.6 (https://github.com/Kuznetsov-Artyom/llvm-nnsu-2024 d0378b668d4e9e7b60a19069049f55c257d8a3bf)"} - -... ---- -name: _Z12muladd_test1Dv2_dS_S_ -alignment: 16 -exposesReturnsTwice: false -legalized: false -regBankSelected: false -selected: false -failedISel: false -tracksRegLiveness: true -hasWinCFI: false -callsEHReturn: false -callsUnwindInit: false -hasEHCatchret: false -hasEHScopes: false -hasEHFunclets: false -isOutlined: false -debugInstrRef: true -failsVerification: false -tracksDebugUserValues: true -registers: [] -liveins: - - { reg: '$xmm0', virtual-reg: '' } - - { reg: '$xmm1', virtual-reg: '' } - - { reg: '$xmm2', virtual-reg: '' } -frameInfo: - isFrameAddressTaken: false - isReturnAddressTaken: false - hasStackMap: false - hasPatchPoint: false - stackSize: 0 - offsetAdjustment: 0 - maxAlignment: 1 - adjustsStack: false - hasCalls: false - stackProtector: '' - functionContext: '' - maxCallFrameSize: 0 - cvBytesOfCalleeSavedRegisters: 0 - hasOpaqueSPAdjustment: false - hasVAStart: false - hasMustTailInVarArgFunc: false - hasTailCall: false - localFrameSize: 0 - savePoint: '' - restorePoint: '' -fixedStack: [] -stack: [] -entry_values: [] -callSites: [] -debugValueSubstitutions: [] -constants: [] -machineFunctionInfo: {} -body: | - bb.0.entry: - liveins: $xmm0, $xmm1, $xmm2 - - $xmm0 = VFMADD213PDZ128r $xmm0, $xmm1, $xmm2, implicit $mxcsr - RET64 $xmm0 - -... ---- -name: _Z12muladd_test2Dv2_dS_S_ -alignment: 16 -exposesReturnsTwice: false -legalized: false -regBankSelected: false -selected: false -failedISel: false -tracksRegLiveness: true -hasWinCFI: false -callsEHReturn: false -callsUnwindInit: false -hasEHCatchret: false -hasEHScopes: false -hasEHFunclets: false -isOutlined: false -debugInstrRef: true -failsVerification: false -tracksDebugUserValues: true -registers: [] -liveins: - - { reg: '$xmm0', virtual-reg: '' } - - { reg: '$xmm1', virtual-reg: '' } - - { reg: '$xmm2', virtual-reg: '' } -frameInfo: - isFrameAddressTaken: false - isReturnAddressTaken: false - hasStackMap: false - hasPatchPoint: false - stackSize: 0 - offsetAdjustment: 0 - maxAlignment: 1 - adjustsStack: false - hasCalls: false - stackProtector: '' - functionContext: '' - maxCallFrameSize: 0 - cvBytesOfCalleeSavedRegisters: 0 - hasOpaqueSPAdjustment: false - hasVAStart: false - hasMustTailInVarArgFunc: false - hasTailCall: false - localFrameSize: 0 - savePoint: '' - restorePoint: '' -fixedStack: [] -stack: [] -entry_values: [] -callSites: [] -debugValueSubstitutions: [] -constants: [] -machineFunctionInfo: {} -body: | - bb.0.entry: - liveins: $xmm0, $xmm1, $xmm2 - - $xmm0 = VFMADD213PDZ128r $xmm0, $xmm1, $xmm2, implicit $mxcsr - RET64 $xmm0 - -... ---- -name: _Z12muladd_test3Dv2_dS_S_ -alignment: 16 -exposesReturnsTwice: false -legalized: false -regBankSelected: false -selected: false -failedISel: false -tracksRegLiveness: true -hasWinCFI: false -callsEHReturn: false -callsUnwindInit: false -hasEHCatchret: false -hasEHScopes: false -hasEHFunclets: false -isOutlined: false -debugInstrRef: true -failsVerification: false -tracksDebugUserValues: true -registers: [] -liveins: - - { reg: '$xmm0', virtual-reg: '' } - - { reg: '$xmm1', virtual-reg: '' } - - { reg: '$xmm2', virtual-reg: '' } -frameInfo: - isFrameAddressTaken: false - isReturnAddressTaken: false - hasStackMap: false - hasPatchPoint: false - stackSize: 0 - offsetAdjustment: 0 - maxAlignment: 1 - adjustsStack: false - hasCalls: false - stackProtector: '' - functionContext: '' - maxCallFrameSize: 0 - cvBytesOfCalleeSavedRegisters: 0 - hasOpaqueSPAdjustment: false - hasVAStart: false - hasMustTailInVarArgFunc: false - hasTailCall: false - localFrameSize: 0 - savePoint: '' - restorePoint: '' -fixedStack: [] -stack: [] -entry_values: [] -callSites: [] -debugValueSubstitutions: [] -constants: [] -machineFunctionInfo: {} -body: | - bb.0.entry: - liveins: $xmm0, $xmm1, $xmm2 - - $xmm0 = VFMADD213PDZ128r $xmm0, $xmm2, $xmm1, implicit $mxcsr - $xmm0 = VFMADD213PDZ128r $xmm0, $xmm2, $xmm1, implicit $mxcsr - RET64 $xmm0 - -... ---- -name: _Z12muladd_test4Dv2_dS_S_ -alignment: 16 -exposesReturnsTwice: false -legalized: false -regBankSelected: false -selected: false -failedISel: false -tracksRegLiveness: true -hasWinCFI: false -callsEHReturn: false -callsUnwindInit: false -hasEHCatchret: false -hasEHScopes: false -hasEHFunclets: false -isOutlined: false -debugInstrRef: true -failsVerification: false -tracksDebugUserValues: true -registers: [] -liveins: - - { reg: '$xmm0', virtual-reg: '' } - - { reg: '$xmm1', virtual-reg: '' } - - { reg: '$xmm2', virtual-reg: '' } -frameInfo: - isFrameAddressTaken: false - isReturnAddressTaken: false - hasStackMap: false - hasPatchPoint: false - stackSize: 0 - offsetAdjustment: 0 - maxAlignment: 1 - adjustsStack: false - hasCalls: false - stackProtector: '' - functionContext: '' - maxCallFrameSize: 0 - cvBytesOfCalleeSavedRegisters: 0 - hasOpaqueSPAdjustment: false - hasVAStart: false - hasMustTailInVarArgFunc: false - hasTailCall: false - localFrameSize: 0 - savePoint: '' - restorePoint: '' -fixedStack: [] -stack: [] -entry_values: [] -callSites: [] -debugValueSubstitutions: [] -constants: [] -machineFunctionInfo: {} -body: | - bb.0.entry: - liveins: $xmm0, $xmm1, $xmm2 - - renamable $xmm0 = nofpexcept MULPDrr killed renamable $xmm0, killed renamable $xmm2, implicit $mxcsr - renamable $xmm0 = nofpexcept DIVPDrr killed renamable $xmm0, renamable $xmm1, implicit $mxcsr - renamable $xmm0 = nofpexcept ADDPDrr killed renamable $xmm0, killed renamable $xmm1, implicit $mxcsr - RET64 $xmm0 - -... ---- -name: _Z12muladd_test5Dv2_dS_S_ -alignment: 16 -exposesReturnsTwice: false -legalized: false -regBankSelected: false -selected: false -failedISel: false -tracksRegLiveness: true -hasWinCFI: false -callsEHReturn: false -callsUnwindInit: false -hasEHCatchret: false -hasEHScopes: false -hasEHFunclets: false -isOutlined: false -debugInstrRef: true -failsVerification: false -tracksDebugUserValues: true -registers: [] -liveins: - - { reg: '$xmm0', virtual-reg: '' } - - { reg: '$xmm1', virtual-reg: '' } - - { reg: '$xmm2', virtual-reg: '' } -frameInfo: - isFrameAddressTaken: false - isReturnAddressTaken: false - hasStackMap: false - hasPatchPoint: false - stackSize: 0 - offsetAdjustment: 0 - maxAlignment: 1 - adjustsStack: false - hasCalls: false - stackProtector: '' - functionContext: '' - maxCallFrameSize: 0 - cvBytesOfCalleeSavedRegisters: 0 - hasOpaqueSPAdjustment: false - hasVAStart: false - hasMustTailInVarArgFunc: false - hasTailCall: false - localFrameSize: 0 - savePoint: '' - restorePoint: '' -fixedStack: [] -stack: [] -entry_values: [] -callSites: [] -debugValueSubstitutions: [] -constants: [] -machineFunctionInfo: {} -body: | - bb.0.entry: - liveins: $xmm0, $xmm1, $xmm2 - - $xmm3 = MOVAPDrr $xmm0 - $xmm3 = VFMADD213PDZ128r $xmm3, $xmm1, $xmm2, implicit $mxcsr - renamable $xmm0 = nofpexcept ADDPDrr killed renamable $xmm0, killed renamable $xmm1, implicit $mxcsr - renamable $xmm0 = nofpexcept SUBPDrr killed renamable $xmm0, renamable $xmm2, implicit $mxcsr - renamable $xmm0 = nofpexcept ADDPDrr killed renamable $xmm0, killed renamable $xmm3, implicit $mxcsr - RET64 $xmm0 - -... ---- -name: _Z12muladd_test6Dv2_dS_S_ -alignment: 16 -exposesReturnsTwice: false -legalized: false -regBankSelected: false -selected: false -failedISel: false -tracksRegLiveness: true -hasWinCFI: false -callsEHReturn: false -callsUnwindInit: false -hasEHCatchret: false -hasEHScopes: false -hasEHFunclets: false -isOutlined: false -debugInstrRef: true -failsVerification: false -tracksDebugUserValues: true -registers: [] -liveins: - - { reg: '$xmm0', virtual-reg: '' } - - { reg: '$xmm1', virtual-reg: '' } - - { reg: '$xmm2', virtual-reg: '' } -frameInfo: - isFrameAddressTaken: false - isReturnAddressTaken: false - hasStackMap: false - hasPatchPoint: false - stackSize: 0 - offsetAdjustment: 0 - maxAlignment: 1 - adjustsStack: false - hasCalls: false - stackProtector: '' - functionContext: '' - maxCallFrameSize: 0 - cvBytesOfCalleeSavedRegisters: 0 - hasOpaqueSPAdjustment: false - hasVAStart: false - hasMustTailInVarArgFunc: false - hasTailCall: false - localFrameSize: 0 - savePoint: '' - restorePoint: '' -fixedStack: [] -stack: [] -entry_values: [] -callSites: [] -debugValueSubstitutions: [] -constants: [] -machineFunctionInfo: {} -body: | - bb.0.entry: - liveins: $xmm0, $xmm1, $xmm2 - - renamable $xmm0 = nofpexcept MULPDrr killed renamable $xmm0, killed renamable $xmm1, implicit $mxcsr - renamable $xmm0 = nofpexcept MULPDrr killed renamable $xmm0, killed renamable $xmm2, implicit $mxcsr - RET64 $xmm0 - -... diff --git a/llvm/test/lab3/kuznetsov_artyom/testing.mir b/llvm/test/lab3/kuznetsov_artyom/testing.mir deleted file mode 100644 index 364cc786eda54..0000000000000 --- a/llvm/test/lab3/kuznetsov_artyom/testing.mir +++ /dev/null @@ -1,285 +0,0 @@ -# RUN: llc -mtriple x86_64-unknown-linux-gnu -run-pass=x86-muladd %s -o - | FileCheck %s - -# test.cpp - -# __m128d muladd_test1(__m128d a, __m128d b, __m128d c) { return a * b + c; } - -# __m128d muladd_test2(__m128d a, __m128d b, __m128d c) { -# __m128d tmp = a * b; -# tmp = tmp + c; -# return tmp; -# } - -# __m128d muladd_test3(__m128d a, __m128d b, __m128d c) { -# __m128d tmp = a * c + b; -# return tmp * c + b; -# } - - ---- | - ; ModuleID = 'test.ll' - source_filename = "test.cpp" - target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" - target triple = "x86_64-unknown-linux-gnu" - - ; Function Attrs: mustprogress nofree nosync nounwind willreturn memory(none) uwtable - define dso_local noundef <2 x double> @_Z12muladd_test1Dv2_dS_S_(<2 x double> noundef %a, <2 x double> noundef %b, <2 x double> noundef %c) local_unnamed_addr #0 { - entry: - %0 = tail call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %a, <2 x double> %b, <2 x double> %c) - ret <2 x double> %0 - } - - ; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none) - declare <2 x double> @llvm.fmuladd.v2f64(<2 x double>, <2 x double>, <2 x double>) #1 - - ; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(none) uwtable - define dso_local noundef <2 x double> @_Z12muladd_test2Dv2_dS_S_(<2 x double> noundef %a, <2 x double> noundef %b, <2 x double> noundef %c) local_unnamed_addr #2 { - entry: - %mul = fmul <2 x double> %a, %b - %add = fadd <2 x double> %mul, %c - ret <2 x double> %add - } - - ; Function Attrs: mustprogress nofree nosync nounwind willreturn memory(none) uwtable - define dso_local noundef <2 x double> @_Z12muladd_test3Dv2_dS_S_(<2 x double> noundef %a, <2 x double> noundef %b, <2 x double> noundef %c) local_unnamed_addr #0 { - entry: - %0 = tail call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %a, <2 x double> %c, <2 x double> %b) - %1 = tail call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %0, <2 x double> %c, <2 x double> %b) - ret <2 x double> %1 - } - - attributes #0 = { mustprogress nofree nosync nounwind willreturn memory(none) uwtable "min-legal-vector-width"="128" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" } - attributes #1 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) } - attributes #2 = { mustprogress nofree norecurse nosync nounwind willreturn memory(none) uwtable "min-legal-vector-width"="128" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" } - - !llvm.module.flags = !{!0, !1, !2, !3} - !llvm.ident = !{!4} - - !0 = !{i32 1, !"wchar_size", i32 4} - !1 = !{i32 8, !"PIC Level", i32 2} - !2 = !{i32 7, !"PIE Level", i32 2} - !3 = !{i32 7, !"uwtable", i32 2} - !4 = !{!"clang version 17.0.6 (https://github.com/Kuznetsov-Artyom/llvm-nnsu-2024 a7816066a7b000bd8961dacdc49fc4d7b6c649f0)"} - -... ---- -name: _Z12muladd_test1Dv2_dS_S_ -alignment: 16 -exposesReturnsTwice: false -legalized: false -regBankSelected: false -selected: false -failedISel: false -tracksRegLiveness: true -hasWinCFI: false -callsEHReturn: false -callsUnwindInit: false -hasEHCatchret: false -hasEHScopes: false -hasEHFunclets: false -isOutlined: false -debugInstrRef: true -failsVerification: false -tracksDebugUserValues: true -registers: [] -liveins: - - { reg: '$xmm0', virtual-reg: '' } - - { reg: '$xmm1', virtual-reg: '' } - - { reg: '$xmm2', virtual-reg: '' } -frameInfo: - isFrameAddressTaken: false - isReturnAddressTaken: false - hasStackMap: false - hasPatchPoint: false - stackSize: 0 - offsetAdjustment: 0 - maxAlignment: 1 - adjustsStack: false - hasCalls: false - stackProtector: '' - functionContext: '' - maxCallFrameSize: 0 - cvBytesOfCalleeSavedRegisters: 0 - hasOpaqueSPAdjustment: false - hasVAStart: false - hasMustTailInVarArgFunc: false - hasTailCall: false - localFrameSize: 0 - savePoint: '' - restorePoint: '' -fixedStack: [] -stack: [] -entry_values: [] -callSites: [] -debugValueSubstitutions: [] -constants: [] -machineFunctionInfo: {} -body: | - bb.0.entry: - liveins: $xmm0, $xmm1, $xmm2 - - renamable $xmm0 = nofpexcept MULPDrr killed renamable $xmm0, killed renamable $xmm1, implicit $mxcsr - renamable $xmm0 = nofpexcept ADDPDrr killed renamable $xmm0, killed renamable $xmm2, implicit $mxcsr - RET64 $xmm0 - - ; CHECK: liveins: $xmm0, $xmm1, $xmm2 - - ; CHECK-NOT: renamable $xmm0 = nofpexcept MULPDrr killed renamable $xmm0, killed renamable $xmm1, implicit $mxcsr - ; CHECK-NOT: renamable $xmm0 = nofpexcept ADDPDrr killed renamable $xmm0, killed renamable $xmm2, implicit $mxcsr - ; CHECK: $xmm0 = VFMADD213PDZ128r $xmm0, $xmm1, $xmm2, implicit $mxcsr - ; CHECK-NOT: renamable $xmm0 = nofpexcept MULPDrr killed renamable $xmm0, killed renamable $xmm1, implicit $mxcsr - ; CHECK-NOT: renamable $xmm0 = nofpexcept ADDPDrr killed renamable $xmm0, killed renamable $xmm2, implicit $mxcsr - - ; CHECK-NEXT: RET64 $xmm0 - -... ---- -name: _Z12muladd_test2Dv2_dS_S_ -alignment: 16 -exposesReturnsTwice: false -legalized: false -regBankSelected: false -selected: false -failedISel: false -tracksRegLiveness: true -hasWinCFI: false -callsEHReturn: false -callsUnwindInit: false -hasEHCatchret: false -hasEHScopes: false -hasEHFunclets: false -isOutlined: false -debugInstrRef: true -failsVerification: false -tracksDebugUserValues: true -registers: [] -liveins: - - { reg: '$xmm0', virtual-reg: '' } - - { reg: '$xmm1', virtual-reg: '' } - - { reg: '$xmm2', virtual-reg: '' } -frameInfo: - isFrameAddressTaken: false - isReturnAddressTaken: false - hasStackMap: false - hasPatchPoint: false - stackSize: 0 - offsetAdjustment: 0 - maxAlignment: 1 - adjustsStack: false - hasCalls: false - stackProtector: '' - functionContext: '' - maxCallFrameSize: 0 - cvBytesOfCalleeSavedRegisters: 0 - hasOpaqueSPAdjustment: false - hasVAStart: false - hasMustTailInVarArgFunc: false - hasTailCall: false - localFrameSize: 0 - savePoint: '' - restorePoint: '' -fixedStack: [] -stack: [] -entry_values: [] -callSites: [] -debugValueSubstitutions: [] -constants: [] -machineFunctionInfo: {} -body: | - bb.0.entry: - liveins: $xmm0, $xmm1, $xmm2 - - renamable $xmm0 = nofpexcept MULPDrr killed renamable $xmm0, killed renamable $xmm1, implicit $mxcsr - renamable $xmm0 = nofpexcept ADDPDrr killed renamable $xmm0, killed renamable $xmm2, implicit $mxcsr - RET64 $xmm0 - - ; CHECK: liveins: $xmm0, $xmm1, $xmm2 - - ; CHECK-NOT: renamable $xmm0 = nofpexcept MULPDrr killed renamable $xmm0, killed renamable $xmm1, implicit $mxcsr - ; CHECK-NOT: renamable $xmm0 = nofpexcept ADDPDrr killed renamable $xmm0, killed renamable $xmm2, implicit $mxcsr - ; CHECK: $xmm0 = VFMADD213PDZ128r $xmm0, $xmm1, $xmm2, implicit $mxcsr - ; CHECK-NOT: renamable $xmm0 = nofpexcept MULPDrr killed renamable $xmm0, killed renamable $xmm1, implicit $mxcsr - ; CHECK-NOT: renamable $xmm0 = nofpexcept ADDPDrr killed renamable $xmm0, killed renamable $xmm2, implicit $mxcsr - - ; CHECK-NEXT: RET64 $xmm0 - -... ---- -name: _Z12muladd_test3Dv2_dS_S_ -alignment: 16 -exposesReturnsTwice: false -legalized: false -regBankSelected: false -selected: false -failedISel: false -tracksRegLiveness: true -hasWinCFI: false -callsEHReturn: false -callsUnwindInit: false -hasEHCatchret: false -hasEHScopes: false -hasEHFunclets: false -isOutlined: false -debugInstrRef: true -failsVerification: false -tracksDebugUserValues: true -registers: [] -liveins: - - { reg: '$xmm0', virtual-reg: '' } - - { reg: '$xmm1', virtual-reg: '' } - - { reg: '$xmm2', virtual-reg: '' } -frameInfo: - isFrameAddressTaken: false - isReturnAddressTaken: false - hasStackMap: false - hasPatchPoint: false - stackSize: 0 - offsetAdjustment: 0 - maxAlignment: 1 - adjustsStack: false - hasCalls: false - stackProtector: '' - functionContext: '' - maxCallFrameSize: 0 - cvBytesOfCalleeSavedRegisters: 0 - hasOpaqueSPAdjustment: false - hasVAStart: false - hasMustTailInVarArgFunc: false - hasTailCall: false - localFrameSize: 0 - savePoint: '' - restorePoint: '' -fixedStack: [] -stack: [] -entry_values: [] -callSites: [] -debugValueSubstitutions: [] -constants: [] -machineFunctionInfo: {} -body: | - bb.0.entry: - liveins: $xmm0, $xmm1, $xmm2 - - renamable $xmm0 = nofpexcept MULPDrr killed renamable $xmm0, renamable $xmm2, implicit $mxcsr - renamable $xmm0 = nofpexcept ADDPDrr killed renamable $xmm0, renamable $xmm1, implicit $mxcsr - renamable $xmm0 = nofpexcept MULPDrr killed renamable $xmm0, killed renamable $xmm2, implicit $mxcsr - renamable $xmm0 = nofpexcept ADDPDrr killed renamable $xmm0, killed renamable $xmm1, implicit $mxcsr - RET64 $xmm0 - - ; CHECK: liveins: $xmm0, $xmm1, $xmm2 - - ; CHECK-NOT: renamable $xmm0 = nofpexcept MULPDrr killed renamable $xmm0, renamable $xmm2, implicit $mxcsr - ; CHECK-NOT: renamable $xmm0 = nofpexcept ADDPDrr killed renamable $xmm0, renamable $xmm1, implicit $mxcsr - ; CHECK: $xmm0 = VFMADD213PDZ128r $xmm0, $xmm2, $xmm1, implicit $mxcsr - ; CHECK-NOT: renamable $xmm0 = nofpexcept MULPDrr killed renamable $xmm0, renamable $xmm2, implicit $mxcsr - ; CHECK-NOT: renamable $xmm0 = nofpexcept ADDPDrr killed renamable $xmm0, renamable $xmm1, implicit $mxcsr - - ; CHECK-NOT: renamable $xmm0 = nofpexcept MULPDrr killed renamable $xmm0, killed renamable $xmm2, implicit $mxcsr - ; CHECK-NOT: renamable $xmm0 = nofpexcept ADDPDrr killed renamable $xmm0, killed renamable $xmm1, implicit $mxcsr - ; CHECK-NEXT: $xmm0 = VFMADD213PDZ128r $xmm0, $xmm2, $xmm1, implicit $mxcsr - ; CHECK-NOT: renamable $xmm0 = nofpexcept MULPDrr killed renamable $xmm0, renamable $xmm2, implicit $mxcsr - ; CHECK-NOT: renamable $xmm0 = nofpexcept ADDPDrr killed renamable $xmm0, renamable $xmm1, implicit $mxcsr - - ; CHECK-NEXT: RET64 $xmm0 - -... From 8e70c48ba651cafb8c2c8ba28575f49548d2709e Mon Sep 17 00:00:00 2001 From: Kuznetsov-Artyom Date: Tue, 23 Apr 2024 05:18:11 +0300 Subject: [PATCH 08/10] delete debug log --- llvm/lib/Target/X86/X86MulAddPass.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/llvm/lib/Target/X86/X86MulAddPass.cpp b/llvm/lib/Target/X86/X86MulAddPass.cpp index e551aa6a489ab..2822af9dd50ea 100644 --- a/llvm/lib/Target/X86/X86MulAddPass.cpp +++ b/llvm/lib/Target/X86/X86MulAddPass.cpp @@ -33,8 +33,6 @@ bool X86MulAddPass::runOnMachineFunction(MachineFunction &machineFunc) { std::vector> deletedInstructions; - llvm::outs() << machineFunc.getName() << '\n'; - for (auto &block : machineFunc) { MachineInstr *mulInstr = nullptr; MachineInstr *addInstr = nullptr; @@ -84,4 +82,4 @@ INITIALIZE_PASS(X86MulAddPass, X86_MULADD_PASS_NAME, X86_MULADD_PASS_NAME, namespace llvm { FunctionPass *createX86MulAddPassPass() { return new X86MulAddPass(); } -} // namespace llvm \ No newline at end of file +} // namespace llvm From 7141a77f96735b7b11e500f971686f4b5c8ed1bd Mon Sep 17 00:00:00 2001 From: Kuznetsov-Artyom Date: Wed, 24 Apr 2024 18:06:47 +0300 Subject: [PATCH 09/10] upd --- llvm/lib/Target/X86/CMakeLists.txt | 2 +- llvm/lib/Target/X86/X86.h | 2 -- llvm/lib/Target/X86/X86TargetMachine.cpp | 1 - llvm/lib/Target/X86/lab3/CMakeLists.txt | 11 ++++++++++ .../X86/lab3/kuznetsov_artyom/CMakeLists.txt | 10 ++++++++++ .../kuznetsov_artyom}/X86MulAddPass.cpp | 20 +++---------------- llvm/test/lab3/kuznetsov_artyom/test.mir | 2 +- 7 files changed, 26 insertions(+), 22 deletions(-) create mode 100644 llvm/lib/Target/X86/lab3/CMakeLists.txt create mode 100644 llvm/lib/Target/X86/lab3/kuznetsov_artyom/CMakeLists.txt rename llvm/lib/Target/X86/{ => lab3/kuznetsov_artyom}/X86MulAddPass.cpp (79%) diff --git a/llvm/lib/Target/X86/CMakeLists.txt b/llvm/lib/Target/X86/CMakeLists.txt index 4ab6c90c775e0..03863a821e973 100644 --- a/llvm/lib/Target/X86/CMakeLists.txt +++ b/llvm/lib/Target/X86/CMakeLists.txt @@ -23,7 +23,6 @@ tablegen(LLVM X86GenFoldTables.inc -gen-x86-fold-tables -asmwriternum=1) add_public_tablegen_target(X86CommonTableGen) set(sources - X86MulAddPass.cpp X86ArgumentStackSlotRebase.cpp X86AsmPrinter.cpp X86AvoidTrailingCall.cpp @@ -119,3 +118,4 @@ add_subdirectory(Disassembler) add_subdirectory(MCA) add_subdirectory(MCTargetDesc) add_subdirectory(TargetInfo) +add_subdirectory(lab3) diff --git a/llvm/lib/Target/X86/X86.h b/llvm/lib/Target/X86/X86.h index 238877f104802..76ecc77bc39c2 100644 --- a/llvm/lib/Target/X86/X86.h +++ b/llvm/lib/Target/X86/X86.h @@ -167,7 +167,6 @@ FunctionPass *createX86LoadValueInjectionRetHardeningPass(); FunctionPass *createX86SpeculativeLoadHardeningPass(); FunctionPass *createX86SpeculativeExecutionSideEffectSuppression(); FunctionPass *createX86ArgumentStackSlotPass(); -FunctionPass *createX86MulAddPassCallPass(); void initializeEvexToVexInstPassPass(PassRegistry &); void initializeFPSPass(PassRegistry &); @@ -202,7 +201,6 @@ void initializeX86ReturnThunksPass(PassRegistry &); void initializeX86SpeculativeExecutionSideEffectSuppressionPass(PassRegistry &); void initializeX86SpeculativeLoadHardeningPassPass(PassRegistry &); void initializeX86TileConfigPass(PassRegistry &); -void initializeX86MulAddPassPass(PassRegistry &); namespace X86AS { enum : unsigned { diff --git a/llvm/lib/Target/X86/X86TargetMachine.cpp b/llvm/lib/Target/X86/X86TargetMachine.cpp index d8aa8b89d8f21..c096e6dd9686c 100644 --- a/llvm/lib/Target/X86/X86TargetMachine.cpp +++ b/llvm/lib/Target/X86/X86TargetMachine.cpp @@ -105,7 +105,6 @@ extern "C" LLVM_EXTERNAL_VISIBILITY void LLVMInitializeX86Target() { initializeX86ReturnThunksPass(PR); initializeX86DAGToDAGISelPass(PR); initializeX86ArgumentStackSlotPassPass(PR); - initializeX86MulAddPassPass(PR); } static std::unique_ptr createTLOF(const Triple &TT) { diff --git a/llvm/lib/Target/X86/lab3/CMakeLists.txt b/llvm/lib/Target/X86/lab3/CMakeLists.txt new file mode 100644 index 0000000000000..c96f18403a78f --- /dev/null +++ b/llvm/lib/Target/X86/lab3/CMakeLists.txt @@ -0,0 +1,11 @@ +if (NOT WIN32 AND NOT CYGWIN) + set(path ${CMAKE_CURRENT_SOURCE_DIR}) + cmake_path(GET path PARENT_PATH PATH_TO_X86) + + FILE(GLOB children RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/*) + FOREACH(child ${children}) + IF(IS_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/${child}) + add_subdirectory(${child}) + ENDIF() + ENDFOREACH() +endif() diff --git a/llvm/lib/Target/X86/lab3/kuznetsov_artyom/CMakeLists.txt b/llvm/lib/Target/X86/lab3/kuznetsov_artyom/CMakeLists.txt new file mode 100644 index 0000000000000..393c2cce8c415 --- /dev/null +++ b/llvm/lib/Target/X86/lab3/kuznetsov_artyom/CMakeLists.txt @@ -0,0 +1,10 @@ +set(PluginName X86MulAddPass) +file(GLOB_RECURSE ALL_SOURCE_FILES *.cpp *.h) +add_llvm_pass_plugin(${PluginName} + ${ALL_SOURCE_FILES} + DEPENDS + intrinsics_gen + X86 + BUILDTREE_ONLY) + +target_include_directories(${PluginName} PUBLIC ${PATH_TO_X86}) diff --git a/llvm/lib/Target/X86/X86MulAddPass.cpp b/llvm/lib/Target/X86/lab3/kuznetsov_artyom/X86MulAddPass.cpp similarity index 79% rename from llvm/lib/Target/X86/X86MulAddPass.cpp rename to llvm/lib/Target/X86/lab3/kuznetsov_artyom/X86MulAddPass.cpp index 2822af9dd50ea..5d795231a3b5c 100644 --- a/llvm/lib/Target/X86/X86MulAddPass.cpp +++ b/llvm/lib/Target/X86/lab3/kuznetsov_artyom/X86MulAddPass.cpp @@ -8,21 +8,12 @@ using namespace llvm; -#define X86_MULADD_PASS_DESC "X86 muladd pass" -#define X86_MULADD_PASS_NAME "x86-muladd" - namespace { class X86MulAddPass : public MachineFunctionPass { public: static char ID; - - X86MulAddPass() : MachineFunctionPass(ID) { - initializeX86MulAddPassPass(*PassRegistry::getPassRegistry()); - } - + X86MulAddPass() : MachineFunctionPass(ID) {} bool runOnMachineFunction(MachineFunction &MF) override; - - StringRef getPassName() const override { return X86_MULADD_PASS_DESC; } }; char X86MulAddPass::ID = 0; @@ -74,12 +65,7 @@ bool X86MulAddPass::runOnMachineFunction(MachineFunction &machineFunc) { return changed; } - } // namespace -INITIALIZE_PASS(X86MulAddPass, X86_MULADD_PASS_NAME, X86_MULADD_PASS_NAME, - false, false) - -namespace llvm { -FunctionPass *createX86MulAddPassPass() { return new X86MulAddPass(); } -} // namespace llvm +static RegisterPass X("x86-muladd", "X86 muladd pass", false, + false); diff --git a/llvm/test/lab3/kuznetsov_artyom/test.mir b/llvm/test/lab3/kuznetsov_artyom/test.mir index 1daebdd7e44b0..0c2e58d5c000d 100644 --- a/llvm/test/lab3/kuznetsov_artyom/test.mir +++ b/llvm/test/lab3/kuznetsov_artyom/test.mir @@ -1,4 +1,4 @@ -# RUN: llc -mtriple x86_64-unknown-linux-gnu -run-pass=x86-muladd %s -o - | FileCheck %s +# RUN: llc -mtriple x86_64-unknown-linux-gnu --load=%llvmshlibdir/X86MulAddPass%shlibext -run-pass=x86-muladd %s -o - | FileCheck %s # test.cpp From be3d941df849bf475efda1f014fa11bf05cad949 Mon Sep 17 00:00:00 2001 From: Kuznetsov-Artyom <110616662+Kuznetsov-Artyom@users.noreply.github.com> Date: Thu, 25 Apr 2024 09:25:04 +0300 Subject: [PATCH 10/10] Update llvm/lib/Target/X86/lab3/kuznetsov_artyom/CMakeLists.txt Co-authored-by: m-ly4 --- llvm/lib/Target/X86/lab3/kuznetsov_artyom/CMakeLists.txt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/llvm/lib/Target/X86/lab3/kuznetsov_artyom/CMakeLists.txt b/llvm/lib/Target/X86/lab3/kuznetsov_artyom/CMakeLists.txt index 393c2cce8c415..02bdb87a524a1 100644 --- a/llvm/lib/Target/X86/lab3/kuznetsov_artyom/CMakeLists.txt +++ b/llvm/lib/Target/X86/lab3/kuznetsov_artyom/CMakeLists.txt @@ -8,3 +8,6 @@ add_llvm_pass_plugin(${PluginName} BUILDTREE_ONLY) target_include_directories(${PluginName} PUBLIC ${PATH_TO_X86}) + +set(LLVM_TEST_DEPENDS ${PluginName} ${LLVM_TEST_DEPENDS} PARENT_SCOPE) +