[PATCH] D102673: [ConstantFolding] Fold constrained arithmetic intrinsics
Sanjay Patel via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Jun 18 09:53:37 PDT 2021
spatel added a reviewer: scanon.
spatel added a subscriber: scanon.
spatel added a comment.
Ping @scanon to comment on whether the exception vs. fold-ability logic seems correct.
================
Comment at: llvm/lib/Analysis/ConstantFolding.cpp:1910-1911
+ RoundingMode RM = RoundingMode::Dynamic;
+ Optional<RoundingMode> ORM = CI->getRoundingMode();
+ if (ORM)
+ RM = *ORM;
----------------
I think this would be easier to read if we made it more like the code above here:
```
Optional<RoundingMode> ORM = CI->getRoundingMode();
// If no rounding mode is specified by the intrinsic or the mode is dynamic,
// try to evaluate using the default mode. If it does not raise an inexact
// exception, rounding was not applied so the result is independent of
// rounding mode.
if (!ORM || *ORM == RoundingMode::Dynamic)
return RoundingMode::NearestTiesToEven;
// Use the mode specified by the intrinsic.
return *ORM;
```
That's assuming I'm reading it correctly right now - are there tests with no RM specified on the intrinsic?
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D102673/new/
https://reviews.llvm.org/D102673
More information about the llvm-commits
mailing list