Open
Description
Testcase:
source_filename = "test.ll"
target triple = "x86_64-unknown-linux-gnu"
define i64 @main() #0 {
%zext.1 = zext i32 -2147483648 to i64
%zext.2 = zext i32 2147483647 to i64
%shl.1 = shl i64 %zext.2, 32
%or.1 = or i64 %zext.1, %shl.1
%call.1 = call i64 @float_fn(i64 44, i64 %or.1, i64 4, ptr null)
%add.1 = add i64 %call.1, 0
%bitcast.1 = bitcast i64 15 to double
%bitcast.2 = bitcast i64 %add.1 to double
%call.2 = call double @llvm.maximumnum.f64(double %bitcast.1, double %bitcast.2)
%bitcast.3 = bitcast double %call.2 to i64
%add.2 = add i64 %bitcast.3, 0
%bitcast.4 = bitcast i64 43 to double
%bitcast.5 = bitcast i64 %add.1 to double
%call.3 = call double @llvm.maximum.f64(double %bitcast.4, double %bitcast.5)
%bitcast.6 = bitcast double %call.3 to i64
%add.3 = add i64 %bitcast.6, 0
%icmp.1 = icmp ne i64 %add.2, 15
%res = zext i1 %icmp.1 to i64
ret i64 %res
}
define internal i64 @float_fn(i64 %arg0, i64 %arg1, i64 %arg2, ptr %arg3) #0 {
ret i64 u0x7ff8000000000000
}
; Function Attrs: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.maximumnum.f64(double, double) #1
; Function Attrs: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.maximum.f64(double, double) #1
attributes #0 = { "target-cpu"="skylake" }
attributes #1 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
Commands:
$ ./llvm/bin/opt good.ll -passes="early-cse" -o bad.bc
$ ./llvm/bin/clang bad.bc -O0 -o bad && ./bad
$ echo $?
130
$ ./llvm/bin/clang good.ll -O0 -o good && ./good
$ echo $?
0
Godbolt: https://godbolt.org/z/jExWdcGqx
Alive2: https://alive2.llvm.org/ce/z/WZDPeF (I added the willreturn attribute to get the value mismatch error msg)