forked from OSchip/llvm-project
R600/SI: Lower i64 SELECT by bitcasting to a vector type
This allows allows us to replace ISD::EXTRACT_ELEMENT, which is lowered using shifts, with ISD::EXTRACT_VECTOR_ELT, which is a no-op. llvm-svn: 205187
This commit is contained in:
parent
7277b008ee
commit
7ea3d6d420
|
@ -796,23 +796,25 @@ SDValue SITargetLowering::LowerSELECT(SDValue Op, SelectionDAG &DAG) const {
|
|||
|
||||
SDLoc DL(Op);
|
||||
SDValue Cond = Op.getOperand(0);
|
||||
SDValue LHS = Op.getOperand(1);
|
||||
SDValue RHS = Op.getOperand(2);
|
||||
|
||||
SDValue Zero = DAG.getConstant(0, MVT::i32);
|
||||
SDValue One = DAG.getConstant(1, MVT::i32);
|
||||
|
||||
SDValue Lo0 = DAG.getNode(ISD::EXTRACT_ELEMENT, DL, MVT::i32, LHS, Zero);
|
||||
SDValue Lo1 = DAG.getNode(ISD::EXTRACT_ELEMENT, DL, MVT::i32, RHS, Zero);
|
||||
SDValue LHS = DAG.getNode(ISD::BITCAST, DL, MVT::v2i32, Op.getOperand(1));
|
||||
SDValue RHS = DAG.getNode(ISD::BITCAST, DL, MVT::v2i32, Op.getOperand(2));
|
||||
|
||||
SDValue Lo0 = DAG.getNode(ISD::EXTRACT_VECTOR_ELT, DL, MVT::i32, LHS, Zero);
|
||||
SDValue Lo1 = DAG.getNode(ISD::EXTRACT_VECTOR_ELT, DL, MVT::i32, RHS, Zero);
|
||||
|
||||
SDValue Lo = DAG.getSelect(DL, MVT::i32, Cond, Lo0, Lo1);
|
||||
|
||||
SDValue Hi0 = DAG.getNode(ISD::EXTRACT_ELEMENT, DL, MVT::i32, LHS, One);
|
||||
SDValue Hi1 = DAG.getNode(ISD::EXTRACT_ELEMENT, DL, MVT::i32, RHS, One);
|
||||
SDValue Hi0 = DAG.getNode(ISD::EXTRACT_VECTOR_ELT, DL, MVT::i32, LHS, One);
|
||||
SDValue Hi1 = DAG.getNode(ISD::EXTRACT_VECTOR_ELT, DL, MVT::i32, RHS, One);
|
||||
|
||||
SDValue Hi = DAG.getSelect(DL, MVT::i32, Cond, Hi0, Hi1);
|
||||
|
||||
return DAG.getNode(ISD::BUILD_PAIR, DL, MVT::i64, Lo, Hi);
|
||||
SDValue Res = DAG.getNode(ISD::BUILD_VECTOR, DL, MVT::v2i32, Lo, Hi);
|
||||
return DAG.getNode(ISD::BITCAST, DL, MVT::i64, Res);
|
||||
}
|
||||
|
||||
SDValue SITargetLowering::LowerSELECT_CC(SDValue Op, SelectionDAG &DAG) const {
|
||||
|
|
|
@ -1686,6 +1686,7 @@ def : BitConvert <f64, i64, VReg_64>;
|
|||
def : BitConvert <v2f32, v2i32, VReg_64>;
|
||||
def : BitConvert <v2i32, v2f32, VReg_64>;
|
||||
def : BitConvert <v2i32, i64, VReg_64>;
|
||||
def : BitConvert <i64, v2i32, VReg_64>;
|
||||
|
||||
def : BitConvert <v4f32, v4i32, VReg_128>;
|
||||
def : BitConvert <v4i32, v4f32, VReg_128>;
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
; RUN: llc < %s -march=r600 -mcpu=SI -verify-machineinstrs | FileCheck %s
|
||||
|
||||
; CHECK-LABEL: @select0
|
||||
; i64 select should be split into two i32 selects, and we shouldn't need
|
||||
; to use a shfit to extract the hi dword of the input.
|
||||
; CHECK-NOT: S_LSHR_B64
|
||||
; CHECK: V_CNDMASK
|
||||
; CHECK: V_CNDMASK
|
||||
define void @select0(i64 addrspace(1)* %out, i32 %cond, i64 %in) {
|
||||
|
|
Loading…
Reference in New Issue