172 lines · plain
1; RUN: llc < %s -mtriple=ve | FileCheck %s2 3;;; Test ‘frem’ Instruction4;;;5;;; Syntax:6;;; <result> = frem ptr <ty> <op1>, <op2> ; yields ty:result7;;;8;;; Overview:9;;; The ‘frem’ instruction returns the remainder from the division of its two10;;; operands.11;;;12;;; Arguments:13;;; The two arguments to the ‘frem’ instruction must be floating-point or14;;; vector of floating-point values. Both arguments must have identical types.15;;;16;;; Semantics:17;;; The value produced is the floating-point remainder of the two operands.18;;; This is the same output as a libm ‘fmod’ function, but without any19;;; possibility of setting errno. The remainder has the same sign as the20;;; dividend. This instruction is assumed to execute in the default21;;; floating-point environment. This instruction can also take any number22;;; of fast-math flags, which are optimization hints to enable otherwise23;;; unsafe floating-point optimizations:24;;;25;;; Example:26;;;27;;; <result> = frem float 4.0, %var ; yields float:result = 4.0 % %var28;;;29;;; Note:30;;; We test only float/double/fp128.31;;; We have no way to generated frem from C source code, so convert fdiv32;;; to frem by using sed program.33 34; Function Attrs: norecurse nounwind readnone35define float @frem_float_var(float %0, float %1) {36; CHECK-LABEL: frem_float_var:37; CHECK: .LBB{{[0-9]+}}_2:38; CHECK-NEXT: lea %s2, fmodf@lo39; CHECK-NEXT: and %s2, %s2, (32)040; CHECK-NEXT: lea.sl %s12, fmodf@hi(, %s2)41; CHECK-NEXT: bsic %s10, (, %s12)42; CHECK-NEXT: or %s11, 0, %s943 %3 = frem float %0, %144 ret float %345}46 47; Function Attrs: norecurse nounwind readnone48define double @frem_double_var(double %0, double %1) {49; CHECK-LABEL: frem_double_var:50; CHECK: .LBB{{[0-9]+}}_2:51; CHECK-NEXT: lea %s2, fmod@lo52; CHECK-NEXT: and %s2, %s2, (32)053; CHECK-NEXT: lea.sl %s12, fmod@hi(, %s2)54; CHECK-NEXT: bsic %s10, (, %s12)55; CHECK-NEXT: or %s11, 0, %s956 %3 = frem double %0, %157 ret double %358}59 60; Function Attrs: norecurse nounwind readnone61define fp128 @frem_quad_var(fp128 %0, fp128 %1) {62; CHECK-LABEL: frem_quad_var:63; CHECK: .LBB{{[0-9]+}}_2:64; CHECK-NEXT: lea %s4, fmodl@lo65; CHECK-NEXT: and %s4, %s4, (32)066; CHECK-NEXT: lea.sl %s12, fmodl@hi(, %s4)67; CHECK-NEXT: bsic %s10, (, %s12)68; CHECK-NEXT: or %s11, 0, %s969 %3 = frem fp128 %0, %170 ret fp128 %371}72 73; Function Attrs: norecurse nounwind readnone74define float @frem_float_zero(float %0) {75; CHECK-LABEL: frem_float_zero:76; CHECK: .LBB{{[0-9]+}}_2:77; CHECK-NEXT: or %s1, 0, %s078; CHECK-NEXT: lea %s0, fmodf@lo79; CHECK-NEXT: and %s0, %s0, (32)080; CHECK-NEXT: lea.sl %s12, fmodf@hi(, %s0)81; CHECK-NEXT: lea.sl %s0, 082; CHECK-NEXT: bsic %s10, (, %s12)83; CHECK-NEXT: or %s11, 0, %s984 %2 = frem float 0.000000e+00, %085 ret float %286}87 88; Function Attrs: norecurse nounwind readnone89define double @frem_double_zero(double %0) {90; CHECK-LABEL: frem_double_zero:91; CHECK: .LBB{{[0-9]+}}_2:92; CHECK-NEXT: or %s1, 0, %s093; CHECK-NEXT: lea %s0, fmod@lo94; CHECK-NEXT: and %s0, %s0, (32)095; CHECK-NEXT: lea.sl %s12, fmod@hi(, %s0)96; CHECK-NEXT: lea.sl %s0, 097; CHECK-NEXT: bsic %s10, (, %s12)98; CHECK-NEXT: or %s11, 0, %s999 %2 = frem double 0.000000e+00, %0100 ret double %2101}102 103; Function Attrs: norecurse nounwind readnone104define fp128 @frem_quad_zero(fp128 %0) {105; CHECK-LABEL: frem_quad_zero:106; CHECK: .LBB{{[0-9]+}}_2:107; CHECK-NEXT: or %s2, 0, %s0108; CHECK-NEXT: or %s3, 0, %s1109; CHECK-NEXT: lea %s0, .LCPI{{[0-9]+}}_0@lo110; CHECK-NEXT: and %s0, %s0, (32)0111; CHECK-NEXT: lea.sl %s4, .LCPI{{[0-9]+}}_0@hi(, %s0)112; CHECK-NEXT: ld %s0, 8(, %s4)113; CHECK-NEXT: ld %s1, (, %s4)114; CHECK-NEXT: lea %s4, fmodl@lo115; CHECK-NEXT: and %s4, %s4, (32)0116; CHECK-NEXT: lea.sl %s12, fmodl@hi(, %s4)117; CHECK-NEXT: bsic %s10, (, %s12)118; CHECK-NEXT: or %s11, 0, %s9119 %2 = frem fp128 0xL00000000000000000000000000000000, %0120 ret fp128 %2121}122 123; Function Attrs: norecurse nounwind readnone124define float @frem_float_cont(float %0) {125; CHECK-LABEL: frem_float_cont:126; CHECK: .LBB{{[0-9]+}}_2:127; CHECK-NEXT: or %s1, 0, %s0128; CHECK-NEXT: lea %s0, fmodf@lo129; CHECK-NEXT: and %s0, %s0, (32)0130; CHECK-NEXT: lea.sl %s12, fmodf@hi(, %s0)131; CHECK-NEXT: lea.sl %s0, -1073741824132; CHECK-NEXT: bsic %s10, (, %s12)133; CHECK-NEXT: or %s11, 0, %s9134 %2 = frem float -2.000000e+00, %0135 ret float %2136}137 138; Function Attrs: norecurse nounwind readnone139define double @frem_double_cont(double %0) {140; CHECK-LABEL: frem_double_cont:141; CHECK: .LBB{{[0-9]+}}_2:142; CHECK-NEXT: or %s1, 0, %s0143; CHECK-NEXT: lea %s0, fmod@lo144; CHECK-NEXT: and %s0, %s0, (32)0145; CHECK-NEXT: lea.sl %s12, fmod@hi(, %s0)146; CHECK-NEXT: lea.sl %s0, -1073741824147; CHECK-NEXT: bsic %s10, (, %s12)148; CHECK-NEXT: or %s11, 0, %s9149 %2 = frem double -2.000000e+00, %0150 ret double %2151}152 153; Function Attrs: norecurse nounwind readnone154define fp128 @frem_quad_cont(fp128 %0) {155; CHECK-LABEL: frem_quad_cont:156; CHECK: .LBB{{[0-9]+}}_2:157; CHECK-NEXT: or %s2, 0, %s0158; CHECK-NEXT: or %s3, 0, %s1159; CHECK-NEXT: lea %s0, .LCPI{{[0-9]+}}_0@lo160; CHECK-NEXT: and %s0, %s0, (32)0161; CHECK-NEXT: lea.sl %s4, .LCPI{{[0-9]+}}_0@hi(, %s0)162; CHECK-NEXT: ld %s0, 8(, %s4)163; CHECK-NEXT: ld %s1, (, %s4)164; CHECK-NEXT: lea %s4, fmodl@lo165; CHECK-NEXT: and %s4, %s4, (32)0166; CHECK-NEXT: lea.sl %s12, fmodl@hi(, %s4)167; CHECK-NEXT: bsic %s10, (, %s12)168; CHECK-NEXT: or %s11, 0, %s9169 %2 = frem fp128 0xL0000000000000000C000000000000000, %0170 ret fp128 %2171}172