[PATCH] D31398: [X86][X86 intrinsics]Folding cmp(sub(a, b), 0) into cmp(a, b) optimization

Sanjay Patel via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Apr 10 16:36:19 PDT 2017


spatel accepted this revision.
spatel added a comment.
This revision is now accepted and ready to land.

LGTM - see inline comments for a couple of cleanups.



================
Comment at: lib/Transforms/InstCombine/InstCombineCalls.cpp:2396
+    // Folding cmp(sub(a,b),0) into cmp(a,b)
+    if (Instruction *I = dyn_cast<Instruction>(II->getArgOperand(0))) {
+      if (I->getOpcode() == Instruction::FSub && I->hasOneUse()) {
----------------
spatel wrote:
> You can use 'auto *' with dyn_cast because the type is obvious.
You missed this nit.


================
Comment at: lib/Transforms/InstCombine/InstCombineCalls.cpp:2407-2410
+          Value *LHS = I->getOperand(0);
+          Value *RHS = I->getOperand(1);
+          II->setArgOperand(0, LHS);
+          II->setArgOperand(1, RHS);
----------------
Giving local names to the operands doesn't add value here IMO, but if you want to do that, I prefer to use "A" and "B" to match the formula in the comment.


https://reviews.llvm.org/D31398





More information about the llvm-commits mailing list