[llvm-commits] [llvm] r155853 - in /llvm/trunk: lib/Target/X86/X86ISelLowering.cpp test/CodeGen/X86/select.ll
Duncan Sands
baldrick at free.fr
Wed May 2 00:31:43 PDT 2012
Hi Manman, it looks like this commit caused PR12721. Can you please take a
look.
Ciao, Duncan.
> Author: mren
> Date: Mon Apr 30 17:51:25 2012
> New Revision: 155853
>
> URL: http://llvm.org/viewvc/llvm-project?rev=155853&view=rev
> Log:
> X86: optimization for -(x != 0)
>
> This patch will optimize -(x != 0) on X86
> FROM
> cmpl $0x01,%edi
> sbbl %eax,%eax
> notl %eax
> TO
> negl %edi
> sbbl %eax %eax
>
> Modified:
> llvm/trunk/lib/Target/X86/X86ISelLowering.cpp
> llvm/trunk/test/CodeGen/X86/select.ll
>
> Modified: llvm/trunk/lib/Target/X86/X86ISelLowering.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86ISelLowering.cpp?rev=155853&r1=155852&r2=155853&view=diff
> ==============================================================================
> --- llvm/trunk/lib/Target/X86/X86ISelLowering.cpp (original)
> +++ llvm/trunk/lib/Target/X86/X86ISelLowering.cpp Mon Apr 30 17:51:25 2012
> @@ -8589,6 +8589,22 @@
> SDValue Y = isAllOnes(Op2) ? Op1 : Op2;
>
> SDValue CmpOp0 = Cmp.getOperand(0);
> + // further optimization for special cases
> + // (select (x != 0), -1, 0) -> neg& sbb
> + // (select (x == 0), 0, -1) -> neg& sbb
> + if (ConstantSDNode *YC = dyn_cast<ConstantSDNode>(Y))
> + if (YC->isNullValue()&&
> + (isAllOnes(Op1) == (CondCode == X86::COND_NE))) {
> + SDVTList VTs = DAG.getVTList(CmpOp0.getValueType(), MVT::i32);
> + SDValue Neg = DAG.getNode(ISD::SUB, DL, VTs,
> + DAG.getConstant(0, CmpOp0.getValueType()),
> + CmpOp0);
> + SDValue Res = DAG.getNode(X86ISD::SETCC_CARRY, DL, Op.getValueType(),
> + DAG.getConstant(X86::COND_B, MVT::i8),
> + SDValue(Neg.getNode(), 1));
> + return Res;
> + }
> +
> Cmp = DAG.getNode(X86ISD::CMP, DL, MVT::i32,
> CmpOp0, DAG.getConstant(1, CmpOp0.getValueType()));
> Cmp = ConvertCmpIfNecessary(Cmp, DAG);
>
> Modified: llvm/trunk/test/CodeGen/X86/select.ll
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/select.ll?rev=155853&r1=155852&r2=155853&view=diff
> ==============================================================================
> --- llvm/trunk/test/CodeGen/X86/select.ll (original)
> +++ llvm/trunk/test/CodeGen/X86/select.ll Mon Apr 30 17:51:25 2012
> @@ -218,3 +218,24 @@
> ; CHECK-NEXT: ret
> }
>
> +; rdar://10961709
> +define i32 @test15(i32 %x) nounwind {
> +entry:
> + %cmp = icmp ne i32 %x, 0
> + %sub = sext i1 %cmp to i32
> + ret i32 %sub
> +; CHECK: test15:
> +; CHECK: negl
> +; CHECK: sbbl
> +}
> +
> +define i32 @test16(i32 %x) nounwind {
> +entry:
> + %c = icmp eq i32 %x, 0
> + %d = select i1 %c, i32 0, i32 -1
> + ret i32 %d
> +; CHECK: test16:
> +; CHECK: negl
> +; CHECK: sbbl
> +}
> +
>
>
> _______________________________________________
> 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