This is an archive of the discontinued LLVM Phabricator instance.

[LegalizeTypes][NFC] Use getConstantOperandVal instead of cast constant getvalue.
ClosedPublic

Authored by Jimerlife on Aug 10 2022, 8:11 PM.

Details

Summary

Use getConstantOperandVal(Num) API instead of cast<ConstantSDNode>(N->getOperand(Num))->getZExtValue().

Diff Detail

Event Timeline

Jimerlife created this revision.Aug 10 2022, 8:11 PM
Herald added a project: Restricted Project. · View Herald TranscriptAug 10 2022, 8:11 PM
Jimerlife requested review of this revision.Aug 10 2022, 8:11 PM
Jimerlife updated this revision to Diff 451712.Aug 10 2022, 8:27 PM
craig.topper added inline comments.Aug 10 2022, 9:12 PM
llvm/lib/CodeGen/SelectionDAG/LegalizeFloatTypes.cpp
2367 ↗(On Diff #451712)

Not sure that I like that we repeated the "1" here when we already have Idx. It's potentially more code too since we need to dereference N again.

RKSimon added inline comments.Aug 11 2022, 2:53 AM
llvm/lib/CodeGen/SelectionDAG/LegalizeFloatTypes.cpp
2367 ↗(On Diff #451712)

+1 We've tended to avoid using getConstantOperand helpers when we're also accessing the raw getOperand() variant - probably just do this in cases where we can then remove the getOperand call

Jimerlife updated this revision to Diff 452061.Aug 11 2022, 8:03 PM
Jimerlife edited the summary of this revision. (Show Details)

address comment

Only use getConstantOperandVal(Num) API instead of cast<ConstantSDNode>(N->getOperand(Num))->getZExtValue(). If We already have Idx, still keeping origin cast form. Thanks your suggestions @craig.topper @RKSimon.

This revision is now accepted and ready to land.Aug 11 2022, 8:55 PM