[llvm-commits] [llvm] r68398 - in /llvm/trunk: lib/CodeGen/SelectionDAG/TargetLowering.cpp test/CodeGen/X86/and-su.ll

Dale Johannesen dalej at apple.com
Wed Apr 8 17:18:45 PDT 2009


This is better than what it was doing before, but it would be valid  
and useful to shorten that load.
Perhaps when looking at the AND?

On Apr 3, 2009, at 1:11 PMPDT, Dan Gohman wrote:
>
> = 
> = 
> = 
> = 
> = 
> = 
> = 
> = 
> ======================================================================
> --- llvm/trunk/lib/CodeGen/SelectionDAG/TargetLowering.cpp (original)
> +++ llvm/trunk/lib/CodeGen/SelectionDAG/TargetLowering.cpp Fri Apr   
> 3 15:11:30 2009
> @@ -1464,6 +1464,7 @@
>       // in the same partial word, see if we can shorten the load.
>       if (DCI.isBeforeLegalize() &&
>           N0.getOpcode() == ISD::AND && C1 == 0 &&
> +          N0.getNode()->hasOneUse() &&
>           isa<LoadSDNode>(N0.getOperand(0)) &&
>           N0.getOperand(0).getNode()->hasOneUse() &&
>           isa<ConstantSDNode>(N0.getOperand(1))) {
>
> Added: llvm/trunk/test/CodeGen/X86/and-su.ll
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/and-su.ll?rev=68398&view=auto
>
> = 
> = 
> = 
> = 
> = 
> = 
> = 
> = 
> ======================================================================
> --- llvm/trunk/test/CodeGen/X86/and-su.ll (added)
> +++ llvm/trunk/test/CodeGen/X86/and-su.ll Fri Apr  3 15:11:30 2009
> @@ -0,0 +1,16 @@
> +; RUN: llvm-as < %s | llc -march=x86 | grep {(%} | count 1
> +
> +; Don't duplicate the load.
> +
> +define fastcc i32 @foo(i32* %p) nounwind {
> +	%t0 = load i32* %p
> +	%t2 = and i32 %t0, 10
> +	%t3 = icmp ne i32 %t2, 0
> +	br i1 %t3, label %bb63, label %bb76
> +
> +bb63:
> +	ret i32 %t2
> +
> +bb76:
> +	ret i32 0
> +}




More information about the llvm-commits mailing list