Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for builtin float comparison operations #3899

Merged
merged 1 commit into from
Apr 20, 2024

Conversation

ppaglilla
Copy link
Contributor

Adds support for builtin comparison operations for floats (==, !=, <, <=, >, >=).

@@ -200,6 +200,28 @@ static auto GetBuiltinICmpPredicate(SemIR::BuiltinFunctionKind builtin_kind,
}
}

// Get the predicate to use for an `fcmp` instruction generated for the
// specified builtin.
static auto GetBuiltinFCmpPredicate(SemIR::BuiltinFunctionKind builtin_kind)
Copy link
Contributor Author

@ppaglilla ppaglilla Apr 19, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is using the ordered variants of fcmp conditions, which I'm not sure is accurate with Carbon's intended behavior. Would love feedback on whether this is okay!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, using ordered comparisons is the intent. I don't think we state this explicitly, but it's implicitly mentioned here and here in the design.

Copy link
Contributor

@zygoloid zygoloid left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great, thank you!

@@ -200,6 +200,28 @@ static auto GetBuiltinICmpPredicate(SemIR::BuiltinFunctionKind builtin_kind,
}
}

// Get the predicate to use for an `fcmp` instruction generated for the
// specified builtin.
static auto GetBuiltinFCmpPredicate(SemIR::BuiltinFunctionKind builtin_kind)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, using ordered comparisons is the intent. I don't think we state this explicitly, but it's implicitly mentioned here and here in the design.

@zygoloid zygoloid added this pull request to the merge queue Apr 19, 2024
Merged via the queue into carbon-language:trunk with commit d28c63d Apr 20, 2024
9 checks passed
chandlerc pushed a commit to chandlerc/carbon-lang that referenced this pull request May 2, 2024
…3899)

Adds support for builtin comparison operations for floats (`==`, `!=`,
`<`, `<=`, `>`, `>=`).
CJ-Johnson pushed a commit to CJ-Johnson/carbon-lang that referenced this pull request May 23, 2024
…3899)

Adds support for builtin comparison operations for floats (`==`, `!=`,
`<`, `<=`, `>`, `>=`).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants