[llvm-commits] [llvm] r130485 - in /llvm/trunk: lib/Transforms/InstCombine/InstCombineShifts.cpp test/Transforms/InstCombine/shift.ll

Devang Patel dpatel at apple.com
Fri Apr 29 14:35:56 PDT 2011


Benjamin,

On Apr 29, 2011, at 1:15 AM, Benjamin Kramer wrote:

> Author: d0k
> Date: Fri Apr 29 03:15:41 2011
> New Revision: 130485
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=130485&view=rev
> Log:
> InstCombine: turn (C1 << A) << C2) into (C1 << C2) << A)

Please set DebugLoc on new Shl, based on A's DebugLoc.

I'm not picking on you. I just started paying attention to this instcombiner issue. I know, there are many of places in instcombiner where we create new instructions without debug location. If you or anyone else has better approach we can use to preserve DebugLoc in instcombiner, I'd like to know!

Thanks,
-
Devang

> 
> Fixes PR9809.
> 
> Modified:
>    llvm/trunk/lib/Transforms/InstCombine/InstCombineShifts.cpp
>    llvm/trunk/test/Transforms/InstCombine/shift.ll
> 
> Modified: llvm/trunk/lib/Transforms/InstCombine/InstCombineShifts.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/InstCombine/InstCombineShifts.cpp?rev=130485&r1=130484&r2=130485&view=diff
> ==============================================================================
> --- llvm/trunk/lib/Transforms/InstCombine/InstCombineShifts.cpp (original)
> +++ llvm/trunk/lib/Transforms/InstCombine/InstCombineShifts.cpp Fri Apr 29 03:15:41 2011
> @@ -644,7 +644,14 @@
>       return &I;
>     }
>   }
> -  
> +
> +  // (C1 << A) << C2) -> (C1 << C2) << A)
> +  Constant *C1, *C2;
> +  Value *A;
> +  if (match(I.getOperand(0), m_OneUse(m_Shl(m_Constant(C1), m_Value(A)))) &&
> +      match(I.getOperand(1), m_Constant(C2)))
> +    return BinaryOperator::CreateShl(ConstantExpr::getShl(C1, C2), A);
> +
>   return 0;    
> }
> 
> 
> Modified: llvm/trunk/test/Transforms/InstCombine/shift.ll
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/shift.ll?rev=130485&r1=130484&r2=130485&view=diff
> ==============================================================================
> --- llvm/trunk/test/Transforms/InstCombine/shift.ll (original)
> +++ llvm/trunk/test/Transforms/InstCombine/shift.ll Fri Apr 29 03:15:41 2011
> @@ -485,3 +485,24 @@
> ; CHECK: ret i8 %tmp551
>   ret i8 %tmp55
> }
> +
> +; PR9809
> +define i32 @test40(i32 %a, i32 %b) nounwind {
> +  %shl1 = shl i32 1, %b
> +  %shl2 = shl i32 %shl1, 2
> +  %div = udiv i32 %a, %shl2
> +  ret i32 %div
> +; CHECK: @test40
> +; CHECK-NEXT: add i32 %b, 2
> +; CHECK-NEXT: lshr i32 %a
> +; CHECK-NEXT: ret i32
> +}
> +
> +define i32 @test41(i32 %a, i32 %b) nounwind {
> +  %1 = shl i32 1, %b
> +  %2 = shl i32 %1, 3
> +  ret i32 %2
> +; CHECK: @test41
> +; CHECK-NEXT: shl i32 8, %b
> +; CHECK-NEXT: ret i32
> +}
> 
> 
> _______________________________________________
> 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