R600: Update for div_fmas intrinsic change
authorMatt Arsenault <Matthew.Arsenault@amd.com>
Tue, 21 Oct 2014 22:21:41 +0000 (22:21 +0000)
committerMatt Arsenault <Matthew.Arsenault@amd.com>
Tue, 21 Oct 2014 22:21:41 +0000 (22:21 +0000)
llvm-svn: 220339

clang/include/clang/Basic/BuiltinsR600.def
clang/lib/CodeGen/CGBuiltin.cpp
clang/test/CodeGenOpenCL/builtins-r600.cl

index 61df903..79a82f7 100644 (file)
@@ -16,8 +16,8 @@
 
 BUILTIN(__builtin_amdgpu_div_scale, "dddbb*", "n")
 BUILTIN(__builtin_amdgpu_div_scalef, "fffbb*", "n")
-BUILTIN(__builtin_amdgpu_div_fmas, "dddd", "nc")
-BUILTIN(__builtin_amdgpu_div_fmasf, "ffff", "nc")
+BUILTIN(__builtin_amdgpu_div_fmas, "ddddb", "nc")
+BUILTIN(__builtin_amdgpu_div_fmasf, "ffffb", "nc")
 BUILTIN(__builtin_amdgpu_div_fixup, "dddd", "nc")
 BUILTIN(__builtin_amdgpu_div_fixupf, "ffff", "nc")
 BUILTIN(__builtin_amdgpu_trig_preop, "ddi", "nc")
index f59cbaa..c4f92ed 100644 (file)
@@ -6153,8 +6153,17 @@ Value *CodeGenFunction::EmitR600BuiltinExpr(unsigned BuiltinID,
     return Result;
   }
   case R600::BI__builtin_amdgpu_div_fmas:
-  case R600::BI__builtin_amdgpu_div_fmasf:
-    return emitTernaryFPBuiltin(*this, E, Intrinsic::AMDGPU_div_fmas);
+  case R600::BI__builtin_amdgpu_div_fmasf: {
+    llvm::Value *Src0 = EmitScalarExpr(E->getArg(0));
+    llvm::Value *Src1 = EmitScalarExpr(E->getArg(1));
+    llvm::Value *Src2 = EmitScalarExpr(E->getArg(2));
+    llvm::Value *Src3 = EmitScalarExpr(E->getArg(3));
+
+    llvm::Value *F = CGM.getIntrinsic(Intrinsic::AMDGPU_div_fmas,
+                                      Src0->getType());
+    llvm::Value *Src3ToBool = Builder.CreateIsNotNull(Src3);
+    return Builder.CreateCall4(F, Src0, Src1, Src2, Src3ToBool);
+  }
   case R600::BI__builtin_amdgpu_div_fixup:
   case R600::BI__builtin_amdgpu_div_fixupf:
     return emitTernaryFPBuiltin(*this, E, Intrinsic::AMDGPU_div_fixup);
index 7167e64..129531f 100644 (file)
@@ -31,16 +31,16 @@ void test_div_scale_f32(global float* out, global int* flagout, float a, float b
 
 // CHECK-LABEL: @test_div_fmas_f32
 // CHECK: call float @llvm.AMDGPU.div.fmas.f32
-void test_div_fmas_f32(global float* out, float a, float b, float c)
+void test_div_fmas_f32(global float* out, float a, float b, float c, int d)
 {
-  *out = __builtin_amdgpu_div_fmasf(a, b, c);
+  *out = __builtin_amdgpu_div_fmasf(a, b, c, d);
 }
 
 // CHECK-LABEL: @test_div_fmas_f64
 // CHECK: call double @llvm.AMDGPU.div.fmas.f64
-void test_div_fmas_f64(global double* out, double a, double b, double c)
+void test_div_fmas_f64(global double* out, double a, double b, double c, int d)
 {
-  *out = __builtin_amdgpu_div_fmas(a, b, c);
+  *out = __builtin_amdgpu_div_fmas(a, b, c, d);
 }
 
 // CHECK-LABEL: @test_div_fixup_f32