[llvm] [AArch64] - Fold and and cmp into tst (PR #110347)

David Green via llvm-commits llvm-commits at lists.llvm.org
Mon Sep 30 23:32:10 PDT 2024


================
@@ -4299,6 +4299,36 @@ static SDValue LowerPREFETCH(SDValue Op, SelectionDAG &DAG) {
                      Op.getOperand(1));
 }
 
+// Converts SETCC (AND X Y) Z ULT -> SETCC (AND X (Y & ~(Z - 1)) 0 EQ when Y is
+// a power of 2. This is then lowered to ANDS X (Y & ~(Z - 1)) which produces a
+// better opt with EmitComparison.
+static void SimplifySetCCIntoEq(ISD::CondCode &CC, SDValue &LHS, SDValue &RHS,
+                                SelectionDAG &DAG, const SDLoc DL) {
+  switch (CC) {
+  default:
+    break;
+  case ISD::SETULT:
----------------
davemgreen wrote:

This can be `if (CC == ISD::SETULT)` if there is only a single entry.

https://github.com/llvm/llvm-project/pull/110347


More information about the llvm-commits mailing list