From 33dd04bfbef9e609c501ec84ca3f3036687f9b44 Mon Sep 17 00:00:00 2001 From: Tom Stellard Date: Tue, 23 Jul 2013 01:47:52 +0000 Subject: [PATCH] R600: Clean up extended load patterns Reviewed-by: Vincent Lejeune llvm-svn: 186914 --- llvm/lib/Target/R600/AMDGPUInstructions.td | 20 +++++++++++++++++-- llvm/lib/Target/R600/R600ISelLowering.cpp | 8 ++++---- llvm/lib/Target/R600/R600Instructions.td | 16 +++++++-------- llvm/lib/Target/R600/SIInstructions.td | 2 +- .../CodeGen/R600/i8-to-double-to-float.ll | 2 +- llvm/test/CodeGen/R600/short-args.ll | 1 + 6 files changed, 33 insertions(+), 16 deletions(-) diff --git a/llvm/lib/Target/R600/AMDGPUInstructions.td b/llvm/lib/Target/R600/AMDGPUInstructions.td index 7197c614763f..b3cbe992d736 100644 --- a/llvm/lib/Target/R600/AMDGPUInstructions.td +++ b/llvm/lib/Target/R600/AMDGPUInstructions.td @@ -92,11 +92,27 @@ def az_extload : PatFrag<(ops node:$ptr), (unindexedload node:$ptr), [{ L->getExtensionType() == ISD::EXTLOAD; }]>; -def zextloadi8_global : PatFrag<(ops node:$ptr), (zextloadi8 node:$ptr), [{ +def az_extloadi8 : PatFrag<(ops node:$ptr), (az_extload node:$ptr), [{ + return cast(N)->getMemoryVT() == MVT::i8; +}]>; + +def az_extloadi8_global : PatFrag<(ops node:$ptr), (az_extloadi8 node:$ptr), [{ return isGlobalLoad(dyn_cast(N)); }]>; -def zextloadi8_constant : PatFrag<(ops node:$ptr), (zextloadi8 node:$ptr), [{ +def az_extloadi8_constant : PatFrag<(ops node:$ptr), (az_extloadi8 node:$ptr), [{ + return isGlobalLoad(dyn_cast(N)); +}]>; + +def az_extloadi16 : PatFrag<(ops node:$ptr), (az_extload node:$ptr), [{ + return cast(N)->getMemoryVT() == MVT::i16; +}]>; + +def az_extloadi16_global : PatFrag<(ops node:$ptr), (az_extloadi16 node:$ptr), [{ + return isGlobalLoad(dyn_cast(N)); +}]>; + +def az_extloadi16_constant : PatFrag<(ops node:$ptr), (az_extloadi16 node:$ptr), [{ return isGlobalLoad(dyn_cast(N)); }]>; diff --git a/llvm/lib/Target/R600/R600ISelLowering.cpp b/llvm/lib/Target/R600/R600ISelLowering.cpp index 1067b38c8fd5..08f0c19ed864 100644 --- a/llvm/lib/Target/R600/R600ISelLowering.cpp +++ b/llvm/lib/Target/R600/R600ISelLowering.cpp @@ -71,10 +71,10 @@ R600TargetLowering::R600TargetLowering(TargetMachine &TM) : setOperationAction(ISD::LOAD, MVT::i32, Custom); setOperationAction(ISD::LOAD, MVT::v2i32, Expand); setOperationAction(ISD::LOAD, MVT::v4i32, Custom); - setLoadExtAction(ISD::EXTLOAD, MVT::v4i8, Custom); - setLoadExtAction(ISD::EXTLOAD, MVT::i8, Custom); - setLoadExtAction(ISD::ZEXTLOAD, MVT::i8, Custom); - setLoadExtAction(ISD::ZEXTLOAD, MVT::v4i8, Custom); + setLoadExtAction(ISD::SEXTLOAD, MVT::i8, Expand); + setLoadExtAction(ISD::SEXTLOAD, MVT::i16, Expand); + setLoadExtAction(ISD::ZEXTLOAD, MVT::i8, Expand); + setLoadExtAction(ISD::ZEXTLOAD, MVT::i16, Expand); setOperationAction(ISD::STORE, MVT::i8, Custom); setOperationAction(ISD::STORE, MVT::i32, Custom); setOperationAction(ISD::STORE, MVT::v2i32, Expand); diff --git a/llvm/lib/Target/R600/R600Instructions.td b/llvm/lib/Target/R600/R600Instructions.td index 3652c89b7270..8a49a8df1d10 100644 --- a/llvm/lib/Target/R600/R600Instructions.td +++ b/llvm/lib/Target/R600/R600Instructions.td @@ -317,8 +317,8 @@ class LoadParamFrag : PatFrag < >; def load_param : LoadParamFrag; -def load_param_zexti8 : LoadParamFrag; -def load_param_zexti16 : LoadParamFrag; +def load_param_exti8 : LoadParamFrag; +def load_param_exti16 : LoadParamFrag; def isR600 : Predicate<"Subtarget.getGeneration() <= AMDGPUSubtarget::R700">; def isR700 : Predicate<"Subtarget.getGeneration() == AMDGPUSubtarget::R700">; @@ -1380,11 +1380,11 @@ class VTX_READ_128_eg buffer_id, list pattern> //===----------------------------------------------------------------------===// def VTX_READ_PARAM_8_eg : VTX_READ_8_eg <0, - [(set i32:$dst_gpr, (load_param_zexti8 ADDRVTX_READ:$src_gpr))] + [(set i32:$dst_gpr, (load_param_exti8 ADDRVTX_READ:$src_gpr))] >; def VTX_READ_PARAM_16_eg : VTX_READ_16_eg <0, - [(set i32:$dst_gpr, (load_param_zexti16 ADDRVTX_READ:$src_gpr))] + [(set i32:$dst_gpr, (load_param_exti16 ADDRVTX_READ:$src_gpr))] >; def VTX_READ_PARAM_32_eg : VTX_READ_32_eg <0, @@ -1401,7 +1401,7 @@ def VTX_READ_PARAM_128_eg : VTX_READ_128_eg <0, // 8-bit reads def VTX_READ_GLOBAL_8_eg : VTX_READ_8_eg <1, - [(set i32:$dst_gpr, (zextloadi8_global ADDRVTX_READ:$src_gpr))] + [(set i32:$dst_gpr, (az_extloadi8_global ADDRVTX_READ:$src_gpr))] >; // 32-bit reads @@ -1828,11 +1828,11 @@ class VTX_READ_128_cm buffer_id, list pattern> // VTX Read from parameter memory space //===----------------------------------------------------------------------===// def VTX_READ_PARAM_8_cm : VTX_READ_8_cm <0, - [(set i32:$dst_gpr, (load_param_zexti8 ADDRVTX_READ:$src_gpr))] + [(set i32:$dst_gpr, (load_param_exti8 ADDRVTX_READ:$src_gpr))] >; def VTX_READ_PARAM_16_cm : VTX_READ_16_cm <0, - [(set i32:$dst_gpr, (load_param_zexti16 ADDRVTX_READ:$src_gpr))] + [(set i32:$dst_gpr, (load_param_exti16 ADDRVTX_READ:$src_gpr))] >; def VTX_READ_PARAM_32_cm : VTX_READ_32_cm <0, @@ -1849,7 +1849,7 @@ def VTX_READ_PARAM_128_cm : VTX_READ_128_cm <0, // 8-bit reads def VTX_READ_GLOBAL_8_cm : VTX_READ_8_cm <1, - [(set i32:$dst_gpr, (zextloadi8_global ADDRVTX_READ:$src_gpr))] + [(set i32:$dst_gpr, (az_extloadi8_global ADDRVTX_READ:$src_gpr))] >; // 32-bit reads diff --git a/llvm/lib/Target/R600/SIInstructions.td b/llvm/lib/Target/R600/SIInstructions.td index 789a5187e498..1ddbd0725022 100644 --- a/llvm/lib/Target/R600/SIInstructions.td +++ b/llvm/lib/Target/R600/SIInstructions.td @@ -1746,7 +1746,7 @@ defm : MUBUFLoad_Pattern ; defm : MUBUFLoad_Pattern ; + az_extloadi8_global, az_extloadi8_constant>; defm : MUBUFLoad_Pattern ; defm : MUBUFLoad_Pattern