[PATCH] D22449: [InstCombine] Minor cleanup of cast simplification code [NFC]

David Majnemer via llvm-commits llvm-commits at lists.llvm.org
Mon Jul 18 09:32:05 PDT 2016


majnemer added a subscriber: majnemer.

================
Comment at: lib/Transforms/InstCombine/InstCombineAndOrXor.cpp:1200
@@ +1199,3 @@
+  // Noop casts and casts of constants should be eliminated trivially.
+  if (CI->getSrcTy() == CI->getDestTy() || isa<Constant>(CastSrc)) return false;
+
----------------
Please put returns on their own line.

================
Comment at: lib/Transforms/InstCombine/InstCombineAndOrXor.cpp:1204
@@ +1203,3 @@
+  // to have it eliminated.
+  if (const CastInst *PrecedingCI = dyn_cast<CastInst>(CastSrc))
+    if (isEliminableCastPair(PrecedingCI, CI))
----------------
`const auto *` would be more concise.

================
Comment at: lib/Transforms/InstCombine/InstCombineAndOrXor.cpp:1262-1264
@@ -1243,4 +1261,5 @@
+  // fold logic(cast(A), cast(B)) -> cast(logic(A, B))
   if ((!isa<ICmpInst>(Cast0Src) || !isa<ICmpInst>(Cast1Src)) &&
-      ShouldOptimizeCast(CastOpcode, Cast0Src, DestTy) &&
-      ShouldOptimizeCast(CastOpcode, Cast1Src, DestTy)) {
+      shouldOptimizeCast(Cast0) &&
+      shouldOptimizeCast(Cast1)) {
     Value *NewOp = Builder->CreateBinOp(LogicOpc, Cast0Src, Cast1Src,
----------------
Please clang-format this.


https://reviews.llvm.org/D22449





More information about the llvm-commits mailing list