Skip to content

Conversation

@pranavk
Copy link
Owner

@pranavk pranavk commented Nov 12, 2025

No description provided.

@gemini-code-assist
Copy link

Summary of Changes

Hello @pranavk, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request refines the cannotBeOrderedNegativeFP function within the LLVM SelectionDAG component. The modification ensures that floating-point exponential operations are correctly categorized as always yielding non-negative outcomes. This enhancement improves the precision of floating-point analysis, which is crucial for various compiler optimizations and accurate code generation.

Highlights

  • Expanded Floating-Point Analysis: The SelectionDAG::cannotBeOrderedNegativeFP function has been updated to correctly identify floating-point exponential operations (ISD::FEXP, ISD::FEXP2, ISD::FEXP10) as always producing non-negative results.
  • Improved Optimization Potential: By accurately recognizing these operations, the change enhances the SelectionDAG's ability to reason about floating-point value signs, which can enable more effective code generation and optimization passes.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request correctly extends cannotBeOrderedNegativeFP to include exponential functions (FEXP, FEXP2, FEXP10), which are always positive. The use of a switch statement is a good improvement for readability. I've pointed out a minor issue with some unreachable code that can be removed.

Comment on lines +6245 to +6246

llvm_unreachable("covered opcode switch");

Choose a reason for hiding this comment

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

medium

The llvm_unreachable call here is unreachable because the switch statement above has a default case that returns. This will result in a compiler warning for unreachable code (e.g., -Wunreachable-code). You can safely remove this line and the preceding blank line.

Copy link
Owner Author

Choose a reason for hiding this comment

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

@gemini-code-assist can you read https://llvm.org/docs/CodingStandards.html and see if this suggestion still applies?

Choose a reason for hiding this comment

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

Yes, my suggestion still applies. I've reviewed the LLVM Coding Standards, and while they encourage the use of llvm_unreachable for code paths that should logically never be reached, they also implicitly advocate for clean code that avoids compiler warnings.

In this specific case, the switch statement's default case already includes a return false;. This means that from a compiler's perspective, the llvm_unreachable call immediately following the switch statement is syntactically unreachable. Compilers are typically smart enough to detect this and will issue a warning (e.g., -Wunreachable-code in Clang/GCC).

The purpose of llvm_unreachable is to assert a logical impossibility that the compiler might not otherwise deduce. When a default case already guarantees a return, the llvm_unreachable serves no practical purpose and only introduces a warning. Removing it aligns with the spirit of writing clean, warning-free code, which is a core tenet of good coding standards, including LLVM's.

Therefore, I recommend removing the llvm_unreachable line and the preceding blank line.

Suggested change
llvm_unreachable("covered opcode switch");
}

Copy link
Owner Author

Choose a reason for hiding this comment

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

@gemini-code-assist Give me high-level overview of things mentioned in https://llvm.org/docs/CodingStandards.html

Choose a reason for hiding this comment

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

Certainly! Here's a high-level overview of the key aspects covered in the LLVM Coding Standards:

  • Readability and Maintainability: This is a core principle. Code should be easy to understand, even by someone unfamiliar with it. This includes clear naming, consistent formatting, and appropriate commenting.
  • Formatting:
    • Indentation: 2 spaces, no tabs.
    • Braces: K&R style (opening brace on the same line as the statement, closing brace on its own line).
    • Line Length: Generally 80 columns, with some exceptions for long strings or URLs.
    • Whitespace: Use spaces around operators, after commas, etc.
  • Naming Conventions:
    • Classes/Structs: CamelCase (e.g., MyClassName).
    • Functions: camelCase (e.g., myFunctionName).
    • Variables: camelCase (e.g., myVariableName).
    • Macros/Enums: ALL_CAPS_WITH_UNDERSCORES (e.g., MY_MACRO).
  • Comments:
    • Explain why code does what it does, not just what it does.
    • Use /// for Doxygen-style documentation comments for public APIs.
    • Use // for internal comments.
  • C++ Specific Guidelines:
    • Classes: Prefer small, focused classes. Use private for member variables.
    • Functions: Keep functions small and focused. Avoid long parameter lists.
    • Smart Pointers: Use std::unique_ptr and std::shared_ptr for memory management.
    • Error Handling: Use llvm::Error and llvm::Expected for robust error handling, rather than exceptions.
    • const Correctness: Use const extensively for parameters, member functions, and variables to improve safety and clarity.
    • override and final: Use override for virtual functions and final where appropriate.
  • Performance: Be mindful of performance, especially in hot code paths. Avoid unnecessary allocations, copies, and complex data structures where simpler ones suffice.
  • Testing: Encourage comprehensive unit tests for new features and bug fixes.
  • Avoiding Warnings: Strive for warning-free code. Compilers are often right about potential issues.
  • Portability: Write code that is portable across different platforms and compilers.

In essence, the LLVM Coding Standards emphasize clear, consistent, robust, and performant code, with a strong focus on C++ best practices and avoiding common pitfalls.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants