[Hexagon] Pattern match a CTZ loop into a call to countTrailingZeros.
[oota-llvm.git] / lib / Target / Hexagon / HexagonISelDAGToDAG.cpp
index 5bb4c095cf0a302bf0eca9a2d0e4fc60478548e5..aaccac8b57a9eebdd6298f3787d8374b35b0c1fc 100644 (file)
@@ -1137,10 +1137,7 @@ SDNode *HexagonDAGToDAGISel::SelectBitOp(SDNode *N) {
       return SelectCode(N);
 
     // Get the bit position.
-    while (!(Val & 1)) {
-      Val >>= 1;
-      ++bitpos;
-    }
+    bitpos = countTrailingZeros(uint64_t(Val));
   } else {
     // For fabs and fneg, it's always the 31st bit.
     bitpos = 31;