[llvm-commits] [Patch] Teach SimplifySetCC that comparing AssertZext i1 against 1 can be rewritten as a compare against 0

Nadav Rotem nrotem at apple.com
Tue Dec 18 21:15:38 PST 2012


LGTM. 

+        if (Op0.getOpcode() == ISD::AssertZext) {
+          EVT ZExtVT = cast<VTSDNode>(Op0.getOperand(1))->getVT();
+          if (ZExtVT == MVT::i1) {
+            return DAG.getSetCC(dl, VT, Op0,
+                                DAG.getConstant(0, Op0.getValueType()),
+                                Cond == ISD::SETEQ ? ISD::SETNE : ISD::SETEQ);
+          }  <---- here
+        }

No need for the extra braces, and you can fold ZExtVT into the IF.

On Dec 18, 2012, at 9:08 PM, Craig Topper <craig.topper at gmail.com> wrote:

> This patch teachs SimplifySetCC that an AssertZext from i1 compared against 1 can be rewritten to compare against 0 with the opposite condition. This allows X86 to use test %al, %al instead of cmp $1, %al. In particular, when branching on the result of a function that returns a bool as seen in the included test case.
> 
> -- 
> ~Craig
> <assertzext.patch>_______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits




More information about the llvm-commits mailing list