Skip to content

Unary operators don't produce overflow flags for integer operations #1477

@andykaylor

Description

@andykaylor

Classic clang codegen sets the nsw flag for the add and sub operations produced for inc, dec, and minus operators on signed integer operations. When lowering through CIR, this flag is not set.

For example:

int f(int b) {
  return ++b;
}

Classic codegen produces:

%inc = add nsw i32 %0, 1

CIR codegen produces:

%5 = add i32 %4, 1

It's not clear to me whether the CIR should also have an attribute for this.

Metadata

Metadata

Assignees

No one assigned

    Labels

    IR differenceA difference in ClangIR-generated LLVM IR that could complicate reusing original CodeGen testsgood first issueGood for newcomers

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions