Skip to content

likely FP miscompile from AArch64 backend #119792

@regehr

Description

@regehr

let's take this IR:

define float @f(float %0, float %1) {
  %3 = fcmp nnan ogt float %0, %1
  %4 = select i1 %3, float %0, float %1
  ret float %4
}

we're lowering it like so:

Johns-MacBook-Pro-2:build regehr$ ~/llvm-project/for-alive/bin/llc -o - foo2.ll
	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 15, 0
	.globl	_f                              ; -- Begin function f
	.p2align	2
_f:                                     ; @f
	.cfi_startproc
; %bb.0:
	fmaxnm	s0, s0, s1
	ret
	.cfi_endproc
                                        ; -- End function
.subsections_via_symbols
Johns-MacBook-Pro-2:build regehr$ 

now let's look at invoking f(+0.0, -0.0). at the LLVM level, the fcmp ogt returns false, so we get -0.0 as the function return value. however, at least on my M1 Mac, I'm getting +0.0 as the result of the emitted fmaxnm when passed those same arguments.

cc @nunoplopes @stephentyrone

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions