This is an archive of the discontinued LLVM Phabricator instance.

[clang] Missed rounding mode use in constant evaluation
ClosedPublic

Authored by sepavloff on Nov 9 2022, 8:14 AM.

Details

Summary

Integer-to-float conversion was handled in constant evaluator with
default rounding mode. This change fixes the behavior and the conversion
is made using rounding mode stored in ImplicitCastExpr node.

Diff Detail

Event Timeline

sepavloff created this revision.Nov 9 2022, 8:14 AM
Herald added a project: Restricted Project. · View Herald TranscriptNov 9 2022, 8:14 AM
sepavloff requested review of this revision.Nov 9 2022, 8:14 AM
Herald added a project: Restricted Project. · View Herald TranscriptNov 9 2022, 8:14 AM
tbaeder added a subscriber: tbaeder.Nov 9 2022, 8:17 AM
tbaeder added inline comments.
clang/lib/AST/ExprConstant.cpp
2653

SrcType was already unused before, but not so is FPO.

tbaeder added inline comments.Nov 9 2022, 8:18 AM
clang/lib/AST/ExprConstant.cpp
2653

now so is FPO.

sepavloff updated this revision to Diff 474303.Nov 9 2022, 10:14 AM

Removed unused parateters from HandleIntToFloatCast

sepavloff updated this revision to Diff 474304.Nov 9 2022, 10:16 AM

Remove accidentally added file

aaron.ballman added a subscriber: jcranmer-intel.

The changes look correct to me, but adding @jcranmer-intel for floating-point expertise.

clang/test/AST/const-fpfeatures.c
37

Should we add a test without the -fexperimental-strict-floating-point on the RUN line?

rjmccall accepted this revision.Nov 16 2022, 12:12 PM

Looks good to me.

This revision is now accepted and ready to land.Nov 16 2022, 12:12 PM
jcranmer-intel accepted this revision.Nov 16 2022, 12:56 PM

Thanks!

clang/test/AST/const-fpfeatures.c
37

Yes, I will remove it.

This revision was automatically updated to reflect the committed changes.