mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-08-23 02:29:18 +00:00
[DAGCombiner] Add support for FCEIL, FFLOOR and FTRUNC vector constant folding
Differential Revision: http://reviews.llvm.org/D8715 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@234179 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
fe42afc0e5
commit
7d424d47d3
@ -8194,11 +8194,10 @@ SDValue DAGCombiner::visitFP_EXTEND(SDNode *N) {
|
||||
|
||||
SDValue DAGCombiner::visitFCEIL(SDNode *N) {
|
||||
SDValue N0 = N->getOperand(0);
|
||||
ConstantFPSDNode *N0CFP = dyn_cast<ConstantFPSDNode>(N0);
|
||||
EVT VT = N->getValueType(0);
|
||||
|
||||
// fold (fceil c1) -> fceil(c1)
|
||||
if (N0CFP)
|
||||
if (isConstantFPBuildVectorOrConstantFP(N0))
|
||||
return DAG.getNode(ISD::FCEIL, SDLoc(N), VT, N0);
|
||||
|
||||
return SDValue();
|
||||
@ -8206,11 +8205,10 @@ SDValue DAGCombiner::visitFCEIL(SDNode *N) {
|
||||
|
||||
SDValue DAGCombiner::visitFTRUNC(SDNode *N) {
|
||||
SDValue N0 = N->getOperand(0);
|
||||
ConstantFPSDNode *N0CFP = dyn_cast<ConstantFPSDNode>(N0);
|
||||
EVT VT = N->getValueType(0);
|
||||
|
||||
// fold (ftrunc c1) -> ftrunc(c1)
|
||||
if (N0CFP)
|
||||
if (isConstantFPBuildVectorOrConstantFP(N0))
|
||||
return DAG.getNode(ISD::FTRUNC, SDLoc(N), VT, N0);
|
||||
|
||||
return SDValue();
|
||||
@ -8218,11 +8216,10 @@ SDValue DAGCombiner::visitFTRUNC(SDNode *N) {
|
||||
|
||||
SDValue DAGCombiner::visitFFLOOR(SDNode *N) {
|
||||
SDValue N0 = N->getOperand(0);
|
||||
ConstantFPSDNode *N0CFP = dyn_cast<ConstantFPSDNode>(N0);
|
||||
EVT VT = N->getValueType(0);
|
||||
|
||||
// fold (ffloor c1) -> ffloor(c1)
|
||||
if (N0CFP)
|
||||
if (isConstantFPBuildVectorOrConstantFP(N0))
|
||||
return DAG.getNode(ISD::FFLOOR, SDLoc(N), VT, N0);
|
||||
|
||||
return SDValue();
|
||||
|
@ -2853,6 +2853,9 @@ SDValue SelectionDAG::getNode(unsigned Opcode, SDLoc DL,
|
||||
break;
|
||||
case ISD::FNEG:
|
||||
case ISD::FABS:
|
||||
case ISD::FCEIL:
|
||||
case ISD::FTRUNC:
|
||||
case ISD::FFLOOR:
|
||||
case ISD::FP_EXTEND:
|
||||
case ISD::TRUNCATE:
|
||||
case ISD::UINT_TO_FP:
|
||||
@ -2870,6 +2873,7 @@ SDValue SelectionDAG::getNode(unsigned Opcode, SDLoc DL,
|
||||
}
|
||||
if (Ops.size() == VT.getVectorNumElements())
|
||||
return getNode(ISD::BUILD_VECTOR, DL, VT, Ops);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -180,3 +180,49 @@ define <8 x float> @nearbyint_v8f32(<8 x float> %p)
|
||||
ret <8 x float> %t
|
||||
}
|
||||
declare <8 x float> @llvm.nearbyint.v8f32(<8 x float> %p)
|
||||
|
||||
;
|
||||
; Constant Folding
|
||||
;
|
||||
|
||||
define <2 x double> @const_floor_v2f64() {
|
||||
; CHECK: const_floor_v2f64
|
||||
; CHECK: movaps {{.*#+}} xmm0 = [-2.000000e+00,2.000000e+00]
|
||||
%t = call <2 x double> @llvm.floor.v2f64(<2 x double> <double -1.5, double 2.5>)
|
||||
ret <2 x double> %t
|
||||
}
|
||||
|
||||
define <4 x float> @const_floor_v4f32() {
|
||||
; CHECK: const_floor_v4f32
|
||||
; CHECK: movaps {{.*#+}} xmm0 = [-4.000000e+00,6.000000e+00,-9.000000e+00,2.000000e+00]
|
||||
%t = call <4 x float> @llvm.floor.v4f32(<4 x float> <float -3.5, float 6.0, float -9.0, float 2.5>)
|
||||
ret <4 x float> %t
|
||||
}
|
||||
|
||||
define <2 x double> @const_ceil_v2f64() {
|
||||
; CHECK: const_ceil_v2f64
|
||||
; CHECK: movaps {{.*#+}} xmm0 = [-1.000000e+00,3.000000e+00]
|
||||
%t = call <2 x double> @llvm.ceil.v2f64(<2 x double> <double -1.5, double 2.5>)
|
||||
ret <2 x double> %t
|
||||
}
|
||||
|
||||
define <4 x float> @const_ceil_v4f32() {
|
||||
; CHECK: const_ceil_v4f32
|
||||
; CHECK: movaps {{.*#+}} xmm0 = [-3.000000e+00,6.000000e+00,-9.000000e+00,3.000000e+00]
|
||||
%t = call <4 x float> @llvm.ceil.v4f32(<4 x float> <float -3.5, float 6.0, float -9.0, float 2.5>)
|
||||
ret <4 x float> %t
|
||||
}
|
||||
|
||||
define <2 x double> @const_trunc_v2f64() {
|
||||
; CHECK: const_trunc_v2f64
|
||||
; CHECK: movaps {{.*#+}} xmm0 = [-1.000000e+00,2.000000e+00]
|
||||
%t = call <2 x double> @llvm.trunc.v2f64(<2 x double> <double -1.5, double 2.5>)
|
||||
ret <2 x double> %t
|
||||
}
|
||||
|
||||
define <4 x float> @const_trunc_v4f32() {
|
||||
; CHECK: const_trunc_v4f32
|
||||
; CHECK: movaps {{.*#+}} xmm0 = [-3.000000e+00,6.000000e+00,-9.000000e+00,2.000000e+00]
|
||||
%t = call <4 x float> @llvm.trunc.v4f32(<4 x float> <float -3.5, float 6.0, float -9.0, float 2.5>)
|
||||
ret <4 x float> %t
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user