Skip to content

Commit 7139c12

Browse files
kazutakahiratatomtor
authored andcommitted
[llvm] Compare std::optional<T> to values directly (NFC) (llvm#143913)
This patch transforms: X && *X == Y to: X == Y where X is of std::optional<T>, and Y is of T or similar.
1 parent 2312064 commit 7139c12

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

llvm/lib/Analysis/ConstantFolding.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2132,7 +2132,7 @@ static bool mayFoldConstrained(ConstrainedFPIntrinsic *CI,
21322132

21332133
// If evaluation raised FP exception, the result can depend on rounding
21342134
// mode. If the latter is unknown, folding is not possible.
2135-
if (ORM && *ORM == RoundingMode::Dynamic)
2135+
if (ORM == RoundingMode::Dynamic)
21362136
return false;
21372137

21382138
// If FP exceptions are ignored, fold the call, even if such exception is
@@ -2418,7 +2418,7 @@ static Constant *ConstantFoldScalarCall1(StringRef Name,
24182418
if (IntrinsicID == Intrinsic::experimental_constrained_rint &&
24192419
St == APFloat::opInexact) {
24202420
std::optional<fp::ExceptionBehavior> EB = CI->getExceptionBehavior();
2421-
if (EB && *EB == fp::ebStrict)
2421+
if (EB == fp::ebStrict)
24222422
return nullptr;
24232423
}
24242424
} else if (U.isSignaling()) {

llvm/lib/IR/Attributes.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,7 @@ Attribute Attribute::getWithCaptureInfo(LLVMContext &Context, CaptureInfo CI) {
295295
Attribute
296296
Attribute::getWithAllocSizeArgs(LLVMContext &Context, unsigned ElemSizeArg,
297297
const std::optional<unsigned> &NumElemsArg) {
298-
assert(!(ElemSizeArg == 0 && NumElemsArg && *NumElemsArg == 0) &&
298+
assert(!(ElemSizeArg == 0 && NumElemsArg == 0) &&
299299
"Invalid allocsize arguments -- given allocsize(0, 0)");
300300
return get(Context, AllocSize, packAllocSizeArgs(ElemSizeArg, NumElemsArg));
301301
}

0 commit comments

Comments
 (0)