<div dir="ltr">Nice, lgtm!</div><div class="gmail_extra"><br><br><div class="gmail_quote">On Tue, Sep 2, 2014 at 1:10 PM, Tom Stellard <span dir="ltr"><<a href="mailto:thomas.stellard@amd.com" target="_blank">thomas.stellard@amd.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Using the intrinsic allows the SelectionDAGBuilder to turn this call<br>
into the FABS Node and also the intrinsic is something the vectorizer knows<br>
how to vectorize.<br>
<br>
This patch also sets the readnone attribute on this call, which should<br>
enable additional optmizations.<br>
---<br>
lib/CodeGen/CGBuiltin.cpp | 21 ++++-----------------<br>
test/CodeGen/builtins.c | 10 +++++-----<br>
2 files changed, 9 insertions(+), 22 deletions(-)<br>
<br>
diff --git a/lib/CodeGen/CGBuiltin.cpp b/lib/CodeGen/CGBuiltin.cpp<br>
index b74038e..9fde1dc 100644<br>
--- a/lib/CodeGen/CGBuiltin.cpp<br>
+++ b/lib/CodeGen/CGBuiltin.cpp<br>
@@ -145,23 +145,10 @@ static RValue EmitBinaryAtomicPost(CodeGenFunction &CGF,<br>
/// EmitFAbs - Emit a call to fabs/fabsf/fabsl, depending on the type of ValTy,<br>
/// which must be a scalar floating point type.<br>
static Value *EmitFAbs(CodeGenFunction &CGF, Value *V, QualType ValTy) {<br>
- const BuiltinType *ValTyP = ValTy->getAs<BuiltinType>();<br>
- assert(ValTyP && "isn't scalar fp type!");<br>
-<br>
- StringRef FnName;<br>
- switch (ValTyP->getKind()) {<br>
- default: llvm_unreachable("Isn't a scalar fp type!");<br>
- case BuiltinType::Float: FnName = "fabsf"; break;<br>
- case BuiltinType::Double: FnName = "fabs"; break;<br>
- case BuiltinType::LongDouble: FnName = "fabsl"; break;<br>
- }<br>
-<br>
- // The prototype is something that takes and returns whatever V's type is.<br>
- llvm::FunctionType *FT = llvm::FunctionType::get(V->getType(), V->getType(),<br>
- false);<br>
- llvm::Value *Fn = CGF.CGM.CreateRuntimeFunction(FT, FnName);<br>
-<br>
- return CGF.EmitNounwindRuntimeCall(Fn, V, "abs");<br>
+ Value *F = CGF.CGM.getIntrinsic(Intrinsic::fabs, V->getType());<br>
+ llvm::CallInst *Call = CGF.Builder.CreateCall(F, V);<br>
+ Call->setDoesNotAccessMemory();<br>
+ return Call;<br>
}<br>
<br>
static RValue emitLibraryCall(CodeGenFunction &CGF, const FunctionDecl *Fn,<br>
diff --git a/test/CodeGen/builtins.c b/test/CodeGen/builtins.c<br>
index 39bd84c..451ed07 100644<br>
--- a/test/CodeGen/builtins.c<br>
+++ b/test/CodeGen/builtins.c<br>
@@ -171,26 +171,26 @@ void bar() {<br>
void test_float_builtins(float F, double D, long double LD) {<br>
volatile int res;<br>
res = __builtin_isinf(F);<br>
- // CHECK: call float @fabsf(float<br>
+ // CHECK: call float @llvm.fabs.f32(float<br>
// CHECK: fcmp oeq float {{.*}}, 0x7FF0000000000000<br>
<br>
res = __builtin_isinf(D);<br>
- // CHECK: call double @fabs(double<br>
+ // CHECK: call double @llvm.fabs.f64(double<br>
// CHECK: fcmp oeq double {{.*}}, 0x7FF0000000000000<br>
<br>
res = __builtin_isinf(LD);<br>
- // CHECK: call x86_fp80 @fabsl(x86_fp80<br>
+ // CHECK: call x86_fp80 @llvm.fabs.f80(x86_fp80<br>
// CHECK: fcmp oeq x86_fp80 {{.*}}, 0xK7FFF8000000000000000<br>
<br>
res = __builtin_isfinite(F);<br>
// CHECK: fcmp oeq float<br>
- // CHECK: call float @fabsf<br>
+ // CHECK: call float @llvm.fabs.f32(float<br>
// CHECK: fcmp une float {{.*}}, 0x7FF0000000000000<br>
// CHECK: and i1<br>
<br>
res = __builtin_isnormal(F);<br>
// CHECK: fcmp oeq float<br>
- // CHECK: call float @fabsf<br>
+ // CHECK: call float @llvm.fabs.f32(float<br>
// CHECK: fcmp ult float {{.*}}, 0x7FF0000000000000<br>
// CHECK: fcmp uge float {{.*}}, 0x3810000000000000<br>
// CHECK: and i1<br>
<span class="HOEnZb"><font color="#888888">--<br>
1.8.5.5<br>
<br>
_______________________________________________<br>
cfe-commits mailing list<br>
<a href="mailto:cfe-commits@cs.uiuc.edu">cfe-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits</a><br>
</font></span></blockquote></div><br></div>