Skip to content

Pass to emit warnings on downcast after widening op? #8817

@mcourteaux

Description

@mcourteaux

Stuff like cast<T>(widening_XXX(a, b)) with both a and b being of type T is an inefficient way to just XXX. This can be generated by doing XXX(a, b) where a is of type T, but b is not of type T yet (such as a user-provided constant).

I propose a pass to emit a warning when this pattern is found. Probably the user has bad code that can be fixed. I'd be in favor of warning for now, instead of optimizing it away I think, as I would want to know about me doing something with the wrong datatypes, and hence I think the operands should be fixed by the user.

Metadata

Metadata

Assignees

No one assigned

    Labels

    dev_meetingTopic to be discussed at the next dev meeting

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions