Skip to content

i32 + u64 produces an overflow error #9277

Closed
@RX14

Description

Reproduce with -1 + 0u64

I'm not entirely sure what's going on here, but the codegen listing is as such:

  %0 = call { i64, i1 } @llvm.uadd.with.overflow.i64(i64 -1, i64 0), !dbg !11649
  %1 = extractvalue { i64, i1 } %0, 0, !dbg !11649
  %2 = extractvalue { i64, i1 } %0, 1, !dbg !11649
  %3 = icmp ult i64 %1, -2147483648, !dbg !11649
  %4 = and i1 false, %3, !dbg !11649
  %5 = icmp ugt i64 %1, 2147483647, !dbg !11649
  %6 = or i1 false, %5, !dbg !11649
  %7 = or i1 %4, %6, !dbg !11649
  %8 = or i1 %2, %7, !dbg !11649
  %9 = call i1 @llvm.expect.i1(i1 %8, i1 false), !dbg !11649
  br i1 %9, label %overflow, label %normal, !dbg !11649

Seems like it should be using a signed add? Perhaps something to do with codegen_binary_extend_int?

Metadata

Assignees

Labels

kind:bugA bug in the code. Does not apply to documentation, specs, etc.topic:compiler:codegen

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions