This is an archive of the discontinued LLVM Phabricator instance.

[flang] Rewrite "1*j" to "(j)", not "j", when j is a variable
ClosedPublic

Authored by klausler on Jun 21 2023, 12:47 PM.

Details

Summary

Expression folding currently unconditionally rewrites "1*j"
to "j", which is wrong when "j" is a variable, as it transforms
an expression into a variable and can lead to incorrect associations
in contexts like an actual argument or an ASSOCIATE selector.
Transform "1*j" to a parenthesized "(j)" when "j" is a variable.
Fixes LLVM bug https://github.com/llvm/llvm-project/issues/63259.

Diff Detail

Event Timeline

klausler created this revision.Jun 21 2023, 12:47 PM
Herald added a project: Restricted Project. · View Herald Transcript
klausler requested review of this revision.Jun 21 2023, 12:47 PM
PeteSteinfeld accepted this revision.Jun 21 2023, 1:16 PM

All builds and tests correctly and looks good.

This revision is now accepted and ready to land.Jun 21 2023, 1:16 PM