[llvm] [NVPTX] Fix lowering of i1 SETCC (PR #115035)
Alex MacLean via llvm-commits
llvm-commits at lists.llvm.org
Wed Dec 4 21:07:29 PST 2024
================
@@ -11874,6 +11874,47 @@ bool TargetLowering::LegalizeSetCCCondCode(SelectionDAG &DAG, EVT VT,
return true;
}
+ // Special case: expand i1 comparisons using logical operations.
+ if (OpVT == MVT::i1) {
----------------
AlexMaclean wrote:
Most of these expansions take advantage of the unique nature of the i1 type. For example consider signed greater than, this will only be true for i1s if and only if the first operand is 0 and the second is -1, hence it can be expressed as ~X & Y. This sort of bit manipulation is of course totally invalid for any larger type.
To see that this transformation is okay for i1, and not for a larger type here is an alive2 where the transform has been expressed on llvm IR: https://alive2.llvm.org/ce/z/6jS_rA
https://github.com/llvm/llvm-project/pull/115035
More information about the llvm-commits
mailing list