mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2025-01-29 13:09:28 +00:00
[DAGCombiner] Tidyup FMINNUM/FMAXNUM constant folding
Enable constant folding for vector splats as well as scalars. Enable constant canonicalization for all scalar and vector constants. llvm-svn: 249978
This commit is contained in:
parent
1d1c56e2df
commit
5eac2607b9
@ -9023,20 +9023,20 @@ SDValue DAGCombiner::visitFNEG(SDNode *N) {
|
||||
SDValue DAGCombiner::visitFMINNUM(SDNode *N) {
|
||||
SDValue N0 = N->getOperand(0);
|
||||
SDValue N1 = N->getOperand(1);
|
||||
const ConstantFPSDNode *N0CFP = dyn_cast<ConstantFPSDNode>(N0);
|
||||
const ConstantFPSDNode *N1CFP = dyn_cast<ConstantFPSDNode>(N1);
|
||||
EVT VT = N->getValueType(0);
|
||||
const ConstantFPSDNode *N0CFP = isConstOrConstSplatFP(N0);
|
||||
const ConstantFPSDNode *N1CFP = isConstOrConstSplatFP(N1);
|
||||
|
||||
if (N0CFP && N1CFP) {
|
||||
const APFloat &C0 = N0CFP->getValueAPF();
|
||||
const APFloat &C1 = N1CFP->getValueAPF();
|
||||
return DAG.getConstantFP(minnum(C0, C1), SDLoc(N), N->getValueType(0));
|
||||
return DAG.getConstantFP(minnum(C0, C1), SDLoc(N), VT);
|
||||
}
|
||||
|
||||
if (N0CFP) {
|
||||
EVT VT = N->getValueType(0);
|
||||
// Canonicalize to constant on RHS.
|
||||
// Canonicalize to constant on RHS.
|
||||
if (isConstantFPBuildVectorOrConstantFP(N0) &&
|
||||
!isConstantFPBuildVectorOrConstantFP(N1))
|
||||
return DAG.getNode(ISD::FMINNUM, SDLoc(N), VT, N1, N0);
|
||||
}
|
||||
|
||||
return SDValue();
|
||||
}
|
||||
@ -9044,20 +9044,20 @@ SDValue DAGCombiner::visitFMINNUM(SDNode *N) {
|
||||
SDValue DAGCombiner::visitFMAXNUM(SDNode *N) {
|
||||
SDValue N0 = N->getOperand(0);
|
||||
SDValue N1 = N->getOperand(1);
|
||||
const ConstantFPSDNode *N0CFP = dyn_cast<ConstantFPSDNode>(N0);
|
||||
const ConstantFPSDNode *N1CFP = dyn_cast<ConstantFPSDNode>(N1);
|
||||
EVT VT = N->getValueType(0);
|
||||
const ConstantFPSDNode *N0CFP = isConstOrConstSplatFP(N0);
|
||||
const ConstantFPSDNode *N1CFP = isConstOrConstSplatFP(N1);
|
||||
|
||||
if (N0CFP && N1CFP) {
|
||||
const APFloat &C0 = N0CFP->getValueAPF();
|
||||
const APFloat &C1 = N1CFP->getValueAPF();
|
||||
return DAG.getConstantFP(maxnum(C0, C1), SDLoc(N), N->getValueType(0));
|
||||
return DAG.getConstantFP(maxnum(C0, C1), SDLoc(N), VT);
|
||||
}
|
||||
|
||||
if (N0CFP) {
|
||||
EVT VT = N->getValueType(0);
|
||||
// Canonicalize to constant on RHS.
|
||||
// Canonicalize to constant on RHS.
|
||||
if (isConstantFPBuildVectorOrConstantFP(N0) &&
|
||||
!isConstantFPBuildVectorOrConstantFP(N1))
|
||||
return DAG.getNode(ISD::FMAXNUM, SDLoc(N), VT, N1, N0);
|
||||
}
|
||||
|
||||
return SDValue();
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user