From be253e797b58a923371c0629052da2ec1d59c3aa Mon Sep 17 00:00:00 2001 From: Krzysztof Parzyszek Date: Tue, 6 Feb 2018 19:08:41 +0000 Subject: [PATCH] [Hexagon] Don't form new-value jumps from floating-point instructions Additionally, verify that the register defined by the producer is a 32-bit register. llvm-svn: 324381 --- .../Target/Hexagon/HexagonNewValueJump.cpp | 16 ++++++++++++++++ .../CodeGen/Hexagon/newvaluejump-float.mir | 19 +++++++++++++++++++ 2 files changed, 35 insertions(+) create mode 100644 llvm/test/CodeGen/Hexagon/newvaluejump-float.mir diff --git a/llvm/lib/Target/Hexagon/HexagonNewValueJump.cpp b/llvm/lib/Target/Hexagon/HexagonNewValueJump.cpp index ffa447cc1311..bb733fed0445 100644 --- a/llvm/lib/Target/Hexagon/HexagonNewValueJump.cpp +++ b/llvm/lib/Target/Hexagon/HexagonNewValueJump.cpp @@ -142,6 +142,22 @@ static bool canBeFeederToNewValueJump(const HexagonInstrInfo *QII, if (QII->isSolo(*II)) return false; + if (QII->isFloat(*II)) + return false; + + // Make sure that the (unique) def operand is a register from IntRegs. + bool HadDef = false; + for (const MachineOperand &Op : II->operands()) { + if (!Op.isReg() || !Op.isDef()) + continue; + if (HadDef) + return false; + HadDef = true; + if (!Hexagon::IntRegsRegClass.contains(Op.getReg())) + return false; + } + assert(HadDef); + // Make sure there there is no 'def' or 'use' of any of the uses of // feeder insn between it's definition, this MI and jump, jmpInst // skipping compare, cmpInst. diff --git a/llvm/test/CodeGen/Hexagon/newvaluejump-float.mir b/llvm/test/CodeGen/Hexagon/newvaluejump-float.mir new file mode 100644 index 000000000000..9cef4cd0da01 --- /dev/null +++ b/llvm/test/CodeGen/Hexagon/newvaluejump-float.mir @@ -0,0 +1,19 @@ +# RUN: llc -march=hexagon -run-pass=hexagon-nvj %s -o - | FileCheck %s + +# Check that we don't generate a new-value jump for a floating-point +# instruction. +# CHECK-NOT: J4_cmpgti_t_jumpnv_t + +--- +name: fred +tracksRegLiveness: true +body: | + bb.0: + liveins: $d0 + $r0 = F2_conv_df2w_chop $d0, implicit $usr + $p0 = C2_cmpgti $r0, 30 + J2_jumpt $p0, %bb.1, implicit-def $pc + bb.1: + J2_jumpr $r31, implicit-def $pc +... +