From 915f29e7245a5bdb8a3209e9715540b60234f5a5 Mon Sep 17 00:00:00 2001 From: Tom Stellard Date: Wed, 9 Oct 2013 23:18:05 -0400 Subject: XXX: SALU --- lib/Target/R600/SIInstrInfo.cpp | 8 +++++++ test/CodeGen/R600/fneg.ll | 47 ++++++++++++++++++++++++++++++----------- 2 files changed, 43 insertions(+), 12 deletions(-) diff --git a/lib/Target/R600/SIInstrInfo.cpp b/lib/Target/R600/SIInstrInfo.cpp index f38cc517357..3b816bb2367 100644 --- a/lib/Target/R600/SIInstrInfo.cpp +++ b/lib/Target/R600/SIInstrInfo.cpp @@ -201,6 +201,14 @@ MachineInstr *SIInstrInfo::commuteInstruction(MachineInstr *MI, return 0; } + // XXX: Commute VOP3 instructions with abs and neg set. + if (isVOP3(MI->getOpcode()) && + (MI->getOperand(AMDGPU::getNamedOperandIdx(MI->getOpcode(), + AMDGPU::OpName::abs)).getImm() || + MI->getOperand(AMDGPU::getNamedOperandIdx(MI->getOpcode(), + AMDGPU::OpName::neg)).getImm())) + return 0; + unsigned Reg = MI->getOperand(1).getReg(); MI->getOperand(1).ChangeToImmediate(MI->getOperand(2).getImm()); MI->getOperand(2).ChangeToRegister(Reg, false); diff --git a/test/CodeGen/R600/fneg.ll b/test/CodeGen/R600/fneg.ll index f7083cd6ca0..702fb33a24e 100644 --- a/test/CodeGen/R600/fneg.ll +++ b/test/CodeGen/R600/fneg.ll @@ -1,8 +1,23 @@ -; RUN: llc < %s -march=r600 -mcpu=redwood | FileCheck %s +; RUN: llc < %s -march=r600 -mcpu=redwood | FileCheck %s --check-prefix=R600-CHECK +; RUN: llc < %s -march=r600 -mcpu=SI -verify-machineinstrs | FileCheck %s --check-prefix=SI-CHECK -; CHECK: @fneg_v2 -; CHECK: -PV -; CHECK: -PV +; R600-CHECK-LABEL: @fneg +; R600-CHECK: -PV +; SI-CHECK-LABEL: @fneg +; SI-CHECK: V_ADD_F32_e64 VGPR{{[0-9]}}, SGPR{{[0-9]}}, 0, 0, 0, 0, 1 +define void @fneg(float addrspace(1)* %out, float %in) { +entry: + %0 = fsub float -0.000000e+00, %in + store float %0, float addrspace(1)* %out + ret void +} + +; R600-CHECK-LABEL: @fneg_v2 +; R600-CHECK: -PV +; R600-CHECK: -PV +; SI-CHECK-LABEL: @fneg_v2 +; SI-CHECK: V_ADD_F32_e64 VGPR{{[0-9]}}, SGPR{{[0-9]}}, 0, 0, 0, 0, 1 +; SI-CHECK: V_ADD_F32_e64 VGPR{{[0-9]}}, SGPR{{[0-9]}}, 0, 0, 0, 0, 1 define void @fneg_v2(<2 x float> addrspace(1)* nocapture %out, <2 x float> %in) { entry: %0 = fsub <2 x float> , %in @@ -10,11 +25,16 @@ entry: ret void } -; CHECK: @fneg_v4 -; CHECK: -PV -; CHECK: -T -; CHECK: -PV -; CHECK: -PV +; R600-CHECK-LABEL: @fneg_v4 +; R600-CHECK: -PV +; R600-CHECK: -T +; R600-CHECK: -PV +; R600-CHECK: -PV +; SI-CHECK-LABEL: @fneg_v4 +; SI-CHECK: V_ADD_F32_e64 VGPR{{[0-9]}}, VGPR{{[0-9]}}, 0, 0, 0, 0, 1 +; SI-CHECK: V_ADD_F32_e64 VGPR{{[0-9]}}, VGPR{{[0-9]}}, 0, 0, 0, 0, 1 +; SI-CHECK: V_ADD_F32_e64 VGPR{{[0-9]}}, VGPR{{[0-9]}}, 0, 0, 0, 0, 1 +; SI-CHECK: V_ADD_F32_e64 VGPR{{[0-9]}}, VGPR{{[0-9]}}, 0, 0, 0, 0, 1 define void @fneg_v4(<4 x float> addrspace(1)* nocapture %out, <4 x float> %in) { entry: %0 = fsub <4 x float> , %in @@ -26,9 +46,12 @@ entry: ; (fneg (f32 bitcast (i32 a))) => (f32 bitcast (xor (i32 a), 0x80000000)) ; unless the target returns true for isNegFree() -; CHECK-NOT: XOR -; CHECK: -KC0[2].Z - +; R600-CHECK-LABEL: @fneg_free +; R600-CHECK-NOT: XOR +; R600-CHECK: -KC0[2].Z +; SI-CHECK-LABEL: @fneg_free +; XXX: We could use V_ADD_F32_e64 with the negate bit here instead. +; SI-CHECK: V_SUB_F32_e64 VGPR{{[0-9]}}, 0.000000e+00, SGPR{{[0-9]}}, 0, 0, 0, 0 define void @fneg_free(float addrspace(1)* %out, i32 %in) { entry: %0 = bitcast i32 %in to float -- cgit v1.2.3