Skip to content

Commit fb5683a

Browse files
toppercakiramenai
authored andcommitted
[SelectionDAG][X86] Use getAllOnesConstant. NFC (#104640)
Part of an effort to make getConstant stricter about implicit truncation when converting uint64_t to APInt.
1 parent fb060d2 commit fb5683a

File tree

2 files changed

+11
-10
lines changed

2 files changed

+11
-10
lines changed

llvm/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4372,7 +4372,7 @@ void DAGTypeLegalizer::ExpandIntRes_MULFIX(SDNode *N, SDValue &Lo,
43724372

43734373
SDValue SatMax, SatMin;
43744374
SDValue NVTZero = DAG.getConstant(0, dl, NVT);
4375-
SDValue NVTNeg1 = DAG.getConstant(-1, dl, NVT);
4375+
SDValue NVTNeg1 = DAG.getAllOnesConstant(dl, NVT);
43764376
EVT BoolNVT = getSetCCResultType(NVT);
43774377

43784378
if (!Signed) {

llvm/lib/Target/X86/X86ISelLowering.cpp

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23593,7 +23593,7 @@ static SDValue LowerVSETCC(SDValue Op, const X86Subtarget &Subtarget,
2359323593

2359423594
if (!FlipSigns && !Invert && ISD::isBuildVectorAllOnes(Op1.getNode())) {
2359523595
Op0 = DAG.getBitcast(MVT::v4i32, Op0);
23596-
Op1 = DAG.getConstant(-1, dl, MVT::v4i32);
23596+
Op1 = DAG.getAllOnesConstant(dl, MVT::v4i32);
2359723597

2359823598
SDValue GT = DAG.getNode(X86ISD::PCMPGT, dl, MVT::v4i32, Op0, Op1);
2359923599
static const int MaskHi[] = { 1, 1, 3, 3 };
@@ -24385,7 +24385,7 @@ static SDValue LowerSIGN_EXTEND_Mask(SDValue Op, const SDLoc &dl,
2438524385
(Subtarget.hasBWI() && WideEltVT.getSizeInBits() <= 16)) {
2438624386
V = DAG.getNode(Op.getOpcode(), dl, WideVT, In);
2438724387
} else {
24388-
SDValue NegOne = DAG.getConstant(-1, dl, WideVT);
24388+
SDValue NegOne = DAG.getAllOnesConstant(dl, WideVT);
2438924389
SDValue Zero = DAG.getConstant(0, dl, WideVT);
2439024390
V = DAG.getSelect(dl, WideVT, In, NegOne, Zero);
2439124391
}
@@ -26089,7 +26089,7 @@ SDValue X86TargetLowering::LowerINTRINSIC_WO_CHAIN(SDValue Op,
2608926089
Op.getOperand(3));
2609026090
} else {
2609126091
SDValue GenCF = DAG.getNode(X86ISD::ADD, dl, CFVTs, Op.getOperand(1),
26092-
DAG.getConstant(-1, dl, MVT::i8));
26092+
DAG.getAllOnesConstant(dl, MVT::i8));
2609326093
Res = DAG.getNode(IntrData->Opc0, dl, VTs, Op.getOperand(2),
2609426094
Op.getOperand(3), GenCF.getValue(1));
2609526095
}
@@ -29370,7 +29370,7 @@ static SDValue LowerShiftByScalarVariable(SDValue Op, SelectionDAG &DAG,
2937029370

2937129371
// Create the mask using vXi16 shifts. For shift-rights we need to move
2937229372
// the upper byte down before splatting the vXi8 mask.
29373-
SDValue BitMask = DAG.getConstant(-1, dl, ExtVT);
29373+
SDValue BitMask = DAG.getAllOnesConstant(dl, ExtVT);
2937429374
BitMask = getTargetVShiftNode(LogicalX86Op, dl, ExtVT, BitMask,
2937529375
BaseShAmt, BaseShAmtIdx, Subtarget, DAG);
2937629376
if (Opcode != ISD::SHL)
@@ -50520,7 +50520,7 @@ static SDValue combineAddOrSubToADCOrSBB(bool IsSub, const SDLoc &DL, EVT VT,
5052050520
// X - SETAE --> adc X, -1
5052150521
return DAG.getNode(IsSub ? X86ISD::ADC : X86ISD::SBB, DL,
5052250522
DAG.getVTList(VT, MVT::i32), X,
50523-
DAG.getConstant(-1, DL, VT), EFLAGS);
50523+
DAG.getAllOnesConstant(DL, VT), EFLAGS);
5052450524
}
5052550525

5052650526
if (CC == X86::COND_BE) {
@@ -50541,7 +50541,7 @@ static SDValue combineAddOrSubToADCOrSBB(bool IsSub, const SDLoc &DL, EVT VT,
5054150541
SDValue NewEFLAGS = NewSub.getValue(EFLAGS.getResNo());
5054250542
return DAG.getNode(IsSub ? X86ISD::ADC : X86ISD::SBB, DL,
5054350543
DAG.getVTList(VT, MVT::i32), X,
50544-
DAG.getConstant(-1, DL, VT), NewEFLAGS);
50544+
DAG.getAllOnesConstant(DL, VT), NewEFLAGS);
5054550545
}
5054650546
}
5054750547

@@ -50600,7 +50600,7 @@ static SDValue combineAddOrSubToADCOrSBB(bool IsSub, const SDLoc &DL, EVT VT,
5060050600
// X + (Z != 0) --> add X, (zext(setne Z, 0)) --> sbb X, -1, (cmp Z, 1)
5060150601
if (CC == X86::COND_NE)
5060250602
return DAG.getNode(IsSub ? X86ISD::ADC : X86ISD::SBB, DL, VTs, X,
50603-
DAG.getConstant(-1ULL, DL, VT), Cmp1.getValue(1));
50603+
DAG.getAllOnesConstant(DL, VT), Cmp1.getValue(1));
5060450604

5060550605
// X - (Z == 0) --> sub X, (zext(sete Z, 0)) --> sbb X, 0, (cmp Z, 1)
5060650606
// X + (Z == 0) --> add X, (zext(sete Z, 0)) --> adc X, 0, (cmp Z, 1)
@@ -50884,8 +50884,9 @@ static SDValue foldXorTruncShiftIntoCmp(SDNode *N, SelectionDAG &DAG) {
5088450884
const TargetLowering &TLI = DAG.getTargetLoweringInfo();
5088550885
EVT SetCCResultType = TLI.getSetCCResultType(DAG.getDataLayout(),
5088650886
*DAG.getContext(), ResultType);
50887-
SDValue Cond = DAG.getSetCC(DL, SetCCResultType, ShiftOp,
50888-
DAG.getConstant(-1, DL, ShiftOpTy), ISD::SETGT);
50887+
SDValue Cond =
50888+
DAG.getSetCC(DL, SetCCResultType, ShiftOp,
50889+
DAG.getAllOnesConstant(DL, ShiftOpTy), ISD::SETGT);
5088950890
if (SetCCResultType != ResultType)
5089050891
Cond = DAG.getNode(ISD::ZERO_EXTEND, DL, ResultType, Cond);
5089150892
return Cond;

0 commit comments

Comments
 (0)