[PATCH] D48970: [DAGCombiner] extend(ifpositive(X)) -> shift-right (not X)

Sanjay Patel via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Jul 6 06:37:07 PDT 2018


spatel added inline comments.


================
Comment at: lib/CodeGen/SelectionDAG/DAGCombiner.cpp:8006
+    // Invert and smear the sign bit:
+    // sext i1 (setgt iN X, -1) --> sra (not X), (N - 1)
+    // zext i1 (setgt iN X, -1) --> srl (not X), (N - 1)
----------------
lebedev.ri wrote:
> We are assuming that we won't get `setge <>, 0`, because some dagcombine already canonicalizes that?
Correct - that transform is done both in instcombine and TargetLowering::SimplifySetCC():

    // Canonicalize GE/LE comparisons to use GT/LT comparisons.

I'll add a comment to make that clear.


https://reviews.llvm.org/D48970





More information about the llvm-commits mailing list