Skip to content

Commit c51578e

Browse files
authored
[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 1ff630d commit c51578e

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
@@ -4390,7 +4390,7 @@ void DAGTypeLegalizer::ExpandIntRes_MULFIX(SDNode *N, SDValue &Lo,
43904390

43914391
SDValue SatMax, SatMin;
43924392
SDValue NVTZero = DAG.getConstant(0, dl, NVT);
4393-
SDValue NVTNeg1 = DAG.getConstant(-1, dl, NVT);
4393+
SDValue NVTNeg1 = DAG.getAllOnesConstant(dl, NVT);
43944394
EVT BoolNVT = getSetCCResultType(NVT);
43954395

43964396
if (!Signed) {

llvm/lib/Target/X86/X86ISelLowering.cpp

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

2360023600
if (!FlipSigns && !Invert && ISD::isBuildVectorAllOnes(Op1.getNode())) {
2360123601
Op0 = DAG.getBitcast(MVT::v4i32, Op0);
23602-
Op1 = DAG.getConstant(-1, dl, MVT::v4i32);
23602+
Op1 = DAG.getAllOnesConstant(dl, MVT::v4i32);
2360323603

2360423604
SDValue GT = DAG.getNode(X86ISD::PCMPGT, dl, MVT::v4i32, Op0, Op1);
2360523605
static const int MaskHi[] = { 1, 1, 3, 3 };
@@ -24391,7 +24391,7 @@ static SDValue LowerSIGN_EXTEND_Mask(SDValue Op, const SDLoc &dl,
2439124391
(Subtarget.hasBWI() && WideEltVT.getSizeInBits() <= 16)) {
2439224392
V = DAG.getNode(Op.getOpcode(), dl, WideVT, In);
2439324393
} else {
24394-
SDValue NegOne = DAG.getConstant(-1, dl, WideVT);
24394+
SDValue NegOne = DAG.getAllOnesConstant(dl, WideVT);
2439524395
SDValue Zero = DAG.getConstant(0, dl, WideVT);
2439624396
V = DAG.getSelect(dl, WideVT, In, NegOne, Zero);
2439724397
}
@@ -26095,7 +26095,7 @@ SDValue X86TargetLowering::LowerINTRINSIC_WO_CHAIN(SDValue Op,
2609526095
Op.getOperand(3));
2609626096
} else {
2609726097
SDValue GenCF = DAG.getNode(X86ISD::ADD, dl, CFVTs, Op.getOperand(1),
26098-
DAG.getConstant(-1, dl, MVT::i8));
26098+
DAG.getAllOnesConstant(dl, MVT::i8));
2609926099
Res = DAG.getNode(IntrData->Opc0, dl, VTs, Op.getOperand(2),
2610026100
Op.getOperand(3), GenCF.getValue(1));
2610126101
}
@@ -29378,7 +29378,7 @@ static SDValue LowerShiftByScalarVariable(SDValue Op, SelectionDAG &DAG,
2937829378

2937929379
// Create the mask using vXi16 shifts. For shift-rights we need to move
2938029380
// the upper byte down before splatting the vXi8 mask.
29381-
SDValue BitMask = DAG.getConstant(-1, dl, ExtVT);
29381+
SDValue BitMask = DAG.getAllOnesConstant(dl, ExtVT);
2938229382
BitMask = getTargetVShiftNode(LogicalX86Op, dl, ExtVT, BitMask,
2938329383
BaseShAmt, BaseShAmtIdx, Subtarget, DAG);
2938429384
if (Opcode != ISD::SHL)
@@ -50580,7 +50580,7 @@ static SDValue combineAddOrSubToADCOrSBB(bool IsSub, const SDLoc &DL, EVT VT,
5058050580
// X - SETAE --> adc X, -1
5058150581
return DAG.getNode(IsSub ? X86ISD::ADC : X86ISD::SBB, DL,
5058250582
DAG.getVTList(VT, MVT::i32), X,
50583-
DAG.getConstant(-1, DL, VT), EFLAGS);
50583+
DAG.getAllOnesConstant(DL, VT), EFLAGS);
5058450584
}
5058550585

5058650586
if (CC == X86::COND_BE) {
@@ -50601,7 +50601,7 @@ static SDValue combineAddOrSubToADCOrSBB(bool IsSub, const SDLoc &DL, EVT VT,
5060150601
SDValue NewEFLAGS = NewSub.getValue(EFLAGS.getResNo());
5060250602
return DAG.getNode(IsSub ? X86ISD::ADC : X86ISD::SBB, DL,
5060350603
DAG.getVTList(VT, MVT::i32), X,
50604-
DAG.getConstant(-1, DL, VT), NewEFLAGS);
50604+
DAG.getAllOnesConstant(DL, VT), NewEFLAGS);
5060550605
}
5060650606
}
5060750607

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

5066550665
// X - (Z == 0) --> sub X, (zext(sete Z, 0)) --> sbb X, 0, (cmp Z, 1)
5066650666
// X + (Z == 0) --> add X, (zext(sete Z, 0)) --> adc X, 0, (cmp Z, 1)
@@ -50944,8 +50944,9 @@ static SDValue foldXorTruncShiftIntoCmp(SDNode *N, SelectionDAG &DAG) {
5094450944
const TargetLowering &TLI = DAG.getTargetLoweringInfo();
5094550945
EVT SetCCResultType = TLI.getSetCCResultType(DAG.getDataLayout(),
5094650946
*DAG.getContext(), ResultType);
50947-
SDValue Cond = DAG.getSetCC(DL, SetCCResultType, ShiftOp,
50948-
DAG.getConstant(-1, DL, ShiftOpTy), ISD::SETGT);
50947+
SDValue Cond =
50948+
DAG.getSetCC(DL, SetCCResultType, ShiftOp,
50949+
DAG.getAllOnesConstant(DL, ShiftOpTy), ISD::SETGT);
5094950950
if (SetCCResultType != ResultType)
5095050951
Cond = DAG.getNode(ISD::ZERO_EXTEND, DL, ResultType, Cond);
5095150952
return Cond;

0 commit comments

Comments
 (0)