[PATCH] Optimize memcmp(x, y, n)==0 for small n and suitably aligned x/y.
David Majnemer
david.majnemer at gmail.com
Wed Jan 14 01:17:07 PST 2015
================
Comment at: lib/Transforms/Utils/SimplifyLibCalls.cpp:955
@@ +954,3 @@
+ // (And same for 16/32 bit.)
+ if (Len <= 8 && !(Len & (Len-1))
+ && isOnlyUsedInZeroEqualityComparison(CI)
----------------
Isn't the RHS just `isPowerOf2_64`?
Also, '8' sounds awfully target specific. I doubt this is the correct number for the MSP430 target.
================
Comment at: lib/Transforms/Utils/SimplifyLibCalls.cpp:956-958
@@ +955,5 @@
+ if (Len <= 8 && !(Len & (Len-1))
+ && isOnlyUsedInZeroEqualityComparison(CI)
+ && getKnownAlignment(LHS, DL, nullptr, CI) >= Len
+ && getKnownAlignment(RHS, DL, nullptr, CI) >= Len) {
+
----------------
This seems strangely formatted, consider running clang-format over these lines.
================
Comment at: lib/Transforms/Utils/SimplifyLibCalls.cpp:960
@@ +959,3 @@
+
+ if (Type *IntType = IntegerType::get(CI->getContext(), Len << 3)) {
+
----------------
There is no need to manually strength-reduce multiplication by eight. Also, this can never fail.
================
Comment at: lib/Transforms/Utils/SimplifyLibCalls.cpp:962-965
@@ +961,6 @@
+
+ Type *LHSPtrTy = PointerType::get(IntType,
+ cast<PointerType>(LHS->getType())->getAddressSpace());
+ Type *RHSPtrTy = PointerType::get(IntType,
+ cast<PointerType>(RHS->getType())->getAddressSpace());
+
----------------
Perhaps:
Type *LHSPtrTy =
IntType->getPointerTo(LHS->getType()->getPointerAddressSpace());
Type *RHSPtrTy =
IntType->getPointerTo(RHS->getType()->getPointerAddressSpace());
http://reviews.llvm.org/D6952
EMAIL PREFERENCES
http://reviews.llvm.org/settings/panel/emailpreferences/
More information about the llvm-commits
mailing list