[llvm-commits] [llvm] r166313 - in /llvm/trunk: lib/Transforms/Scalar/SimplifyLibCalls.cpp test/Transforms/SimplifyLibCalls/FFS.ll
Benjamin Kramer
benny.kra at googlemail.com
Fri Oct 19 13:43:45 PDT 2012
Author: d0k
Date: Fri Oct 19 15:43:44 2012
New Revision: 166313
URL: http://llvm.org/viewvc/llvm-project?rev=166313&view=rev
Log:
SimplifyLibcalls: The return value of ffsll is always i32, even when the input is zero.
Fixes PR13028.
Modified:
llvm/trunk/lib/Transforms/Scalar/SimplifyLibCalls.cpp
llvm/trunk/test/Transforms/SimplifyLibCalls/FFS.ll
Modified: llvm/trunk/lib/Transforms/Scalar/SimplifyLibCalls.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/SimplifyLibCalls.cpp?rev=166313&r1=166312&r2=166313&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/SimplifyLibCalls.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/SimplifyLibCalls.cpp Fri Oct 19 15:43:44 2012
@@ -772,8 +772,8 @@
// Constant fold.
if (ConstantInt *CI = dyn_cast<ConstantInt>(Op)) {
- if (CI->getValue() == 0) // ffs(0) -> 0.
- return Constant::getNullValue(CI->getType());
+ if (CI->isZero()) // ffs(0) -> 0.
+ return B.getInt32(0);
// ffs(c) -> cttz(c)+1
return B.getInt32(CI->getValue().countTrailingZeros() + 1);
}
Modified: llvm/trunk/test/Transforms/SimplifyLibCalls/FFS.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/SimplifyLibCalls/FFS.ll?rev=166313&r1=166312&r2=166313&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/SimplifyLibCalls/FFS.ll (original)
+++ llvm/trunk/test/Transforms/SimplifyLibCalls/FFS.ll Fri Oct 19 15:43:44 2012
@@ -1,6 +1,7 @@
-; Test that the ToAsciiOptimizer works correctly
-; RUN: opt < %s -simplify-libcalls -S | \
-; RUN: not grep "call.*@ffs"
+; Test that FFSOpt works correctly
+; RUN: opt < %s -simplify-libcalls -S | FileCheck %s
+
+; CHECK-NOT: call{{.*}}@ffs
@non_const = external global i32 ; <i32*> [#uses=1]
@@ -34,3 +35,11 @@
%2 = call i32 @ffsll(i64 %0) ; <i32> [#uses=1]
ret i32 %2
}
+
+; PR13028
+define i32 @b() nounwind {
+ %ffs = call i32 @ffsll(i64 0)
+ ret i32 %ffs
+; CHECK: @b
+; CHECK-NEXT: ret i32 0
+}
More information about the llvm-commits
mailing list