This is an archive of the discontinued LLVM Phabricator instance.

[clang] Move int <-> float scalar conversion to a separate function
ClosedPublic

Authored by SaurabhJha on Apr 7 2021, 10:28 AM.

Details

Summary

As prelude to this patch https://reviews.llvm.org/D99037, we want to move the int-float conversion
into a separate function that can be reused by matrix cast

Diff Detail

Event Timeline

SaurabhJha requested review of this revision.Apr 7 2021, 10:28 AM
SaurabhJha created this revision.
Herald added a project: Restricted Project. · View Herald TranscriptApr 7 2021, 10:28 AM
Herald added a subscriber: cfe-commits. · View Herald Transcript
fhahn added inline comments.
clang/lib/CodeGen/CGExprScalar.cpp
1209

now that' this is a separate function, we should be able to just return the created value directly, right? There should be no need for Res

erichkeane added inline comments.Apr 7 2021, 11:30 AM
clang/lib/CodeGen/CGExprScalar.cpp
1209

Yep, I'd also prefer multiple returns. That also cleans up a bunch of hte 'else's in this function.

Hrmph... Phab ate my other comment, which was that the name EmitCastBetweenScalarTypes feels clunky. Does EmitScalarCast or EmitScalarScalarCast sound better and capture the meaning correctly?

Hrmph... Phab ate my other comment, which was that the name EmitCastBetweenScalarTypes feels clunky. Does EmitScalarCast or EmitScalarScalarCast sound better and capture the meaning correctly?

Yeah, good idea. I'll rename it to EmitScalarCast.

Rename the function to EmitScalarCast and directly returning from if branches now

erichkeane accepted this revision.Apr 7 2021, 11:44 AM
This revision is now accepted and ready to land.Apr 7 2021, 11:44 AM

I don't have commit rights so if it looks good to you, please commit on my behalf.

Alright, validating it now, then I'll push.

fhahn added a comment.Apr 7 2021, 12:25 PM

Alright, validating it now, then I'll push.

Thanks Erich!

Alright, validating it now, then I'll push.

Thanks very much.