xref: /aosp_15_r20/external/llvm/test/CodeGen/WebAssembly/copysign-casts.ll (revision 9880d6810fe72a1726cb53787c6711e909410d58)
1*9880d681SAndroid Build Coastguard Worker; RUN: llc < %s -asm-verbose=false | FileCheck %s
2*9880d681SAndroid Build Coastguard Worker
3*9880d681SAndroid Build Coastguard Worker; DAGCombiner oddly folds casts into the rhs of copysign. Test that they get
4*9880d681SAndroid Build Coastguard Worker; unfolded.
5*9880d681SAndroid Build Coastguard Worker
6*9880d681SAndroid Build Coastguard Workertarget datalayout = "e-m:e-p:32:32-i64:64-n32:64-S128"
7*9880d681SAndroid Build Coastguard Workertarget triple = "wasm32-unknown-unknown"
8*9880d681SAndroid Build Coastguard Worker
9*9880d681SAndroid Build Coastguard Workerdeclare double @copysign(double, double) nounwind readnone
10*9880d681SAndroid Build Coastguard Workerdeclare float @copysignf(float, float) nounwind readnone
11*9880d681SAndroid Build Coastguard Worker
12*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: fold_promote:
13*9880d681SAndroid Build Coastguard Worker; CHECK: f64.promote/f32 $push0=, $1{{$}}
14*9880d681SAndroid Build Coastguard Worker; CHECK: f64.copysign    $push1=, $0, $pop0{{$}}
15*9880d681SAndroid Build Coastguard Workerdefine double @fold_promote(double %a, float %b) {
16*9880d681SAndroid Build Coastguard Worker  %c = fpext float %b to double
17*9880d681SAndroid Build Coastguard Worker  %t = call double @copysign(double %a, double %c)
18*9880d681SAndroid Build Coastguard Worker  ret double %t
19*9880d681SAndroid Build Coastguard Worker}
20*9880d681SAndroid Build Coastguard Worker
21*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: fold_demote:{{$}}
22*9880d681SAndroid Build Coastguard Worker; CHECK: f32.demote/f64  $push0=, $1{{$}}
23*9880d681SAndroid Build Coastguard Worker; CHECK: f32.copysign    $push1=, $0, $pop0{{$}}
24*9880d681SAndroid Build Coastguard Workerdefine float @fold_demote(float %a, double %b) {
25*9880d681SAndroid Build Coastguard Worker  %c = fptrunc double %b to float
26*9880d681SAndroid Build Coastguard Worker  %t = call float @copysignf(float %a, float %c)
27*9880d681SAndroid Build Coastguard Worker  ret float %t
28*9880d681SAndroid Build Coastguard Worker}
29