From abf654288c2f7f0ee6e1dd3e34b70c1aabe82ea7 Mon Sep 17 00:00:00 2001 From: Felix Rath Date: Fri, 24 May 2019 15:44:06 +0200 Subject: Implement handling of the llvm.fabs intrinsic --- test/Intrinsics/fabs.ll | 81 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 81 insertions(+) create mode 100644 test/Intrinsics/fabs.ll (limited to 'test') diff --git a/test/Intrinsics/fabs.ll b/test/Intrinsics/fabs.ll new file mode 100644 index 00000000..80febf70 --- /dev/null +++ b/test/Intrinsics/fabs.ll @@ -0,0 +1,81 @@ +; LLVM has an intrinsic for fabs. +; This file is generated from the following code: +; ``` +;#include +; +;int main(void) { +; float f = -1.; +; f = fabs(f); +; +; if(f != 1.) +; return 1; +; +; double d = -2.; +; d = fabs(d); +; +; if(d != 2.) +; return 2; +; +; return 0; +;} +; ``` +; To clean the resulting llvm-ir up for LLVM-versions < 6, +; I ran `opt -S -strip -strip-debug -strip-named-metadata' +; on the resulting ir. Additionally I removed the 'speculatable' +; attribute where it appeared. +; +; RUN: %llvmas %s -o=%t.bc +; RUN: rm -rf %t.klee-out +; RUN: %klee -exit-on-error --output-dir=%t.klee-out --optimize=false %t.bc +; ModuleID = 'fabs.c' +target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" +target triple = "x86_64-pc-linux-gnu" + +; Function Attrs: noinline nounwind optnone sspstrong uwtable +define i32 @main() #0 { + %1 = alloca i32, align 4 + %2 = alloca float, align 4 + %3 = alloca double, align 8 + store i32 0, i32* %1, align 4 + store float -1.000000e+00, float* %2, align 4 + %4 = load float, float* %2, align 4 + %5 = fpext float %4 to double + %6 = call double @llvm.fabs.f64(double %5) + %7 = fptrunc double %6 to float + store float %7, float* %2, align 4 + %8 = load float, float* %2, align 4 + %9 = fpext float %8 to double + %10 = fcmp une double %9, 1.000000e+00 + br i1 %10, label %11, label %12 + +;