Skip to content

miscompilation of smul.with.overflow.i2 by arm64 backend #55644

@regehr

Description

@regehr

here's a function:

define i1 @f(i2 %0) {
  %2 = call { i2, i1 } @llvm.smul.with.overflow.i2(i2 %0, i2 -2)
  %3 = extractvalue { i2, i1 } %2, 1
  ret i1 %3
}

declare { i2, i1 } @llvm.smul.with.overflow.i2(i2, i2)

clearly f(1) -> 0 because you can't get an overflow when multiplying by 1 but using this driver:

#include <stdio.h>

unsigned f(unsigned);

int main(void) {
  printf("%u\n", f(1));
}

we get:

Johns-MacBook-Pro:~ regehr$ llc foo.ll
Johns-MacBook-Pro:~ regehr$ clang foo.c foo.s && ./a.out
1
Johns-MacBook-Pro:~ regehr$ 

cc @ornata @nunoplopes @ryan-berger @nbushehri @zhengyang92 @aqjune

Metadata

Metadata

Assignees

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions