[llvm] r179786 - In the function InstCombiner::visitExtractElementInst() removed the limitation that extract is promoted over a cast only if the cast has only one use.

Dmitry Babokin babokin at gmail.com
Mon Apr 22 07:20:34 PDT 2013


This commit introduces a regression. Please see bug
http://llvm.org/bugs/show_bug.cgi?id=15818 for more details.

The illegal transformation is the following:
Before:
  %retval.i.i = bitcast <8 x float> %floatval.i.i to <8 x i32>
  %vf.i = bitcast <8 x i32> %retval.i.i to <8 x float>
  %aFOO_load20_offset_load_to_int32 = fptosi <8 x float> %vf.i to <8 x i32>
  %b_load28_to_int32 = fptosi float %b to i32
  %sub_b_load28_to_int32_ = add i32 %b_load28_to_int32, -2
  %v.i.i = extractelement <8 x i32> %aFOO_load20_offset_load_to_int32, i32
%sub_b_load28_to_int32_
After:
  %0 = extractelement <8 x float> %floatval.i.i, i32 %sub_b_load28_to_int32_
  %b_load28_to_int32 = fptosi float %b to i32
  %sub_b_load28_to_int32_ = add i32 %b_load28_to_int32, -2
  %v.i.i = fptosi float %0 to i32

Note that %sub_b_load28_to_int32_ use move before definition.

-Dmitry



On Thu, Apr 18, 2013 at 9:56 PM, Anat Shemer <anat.shemer at intel.com> wrote:

> Author: ashemer
> Date: Thu Apr 18 14:56:44 2013
> New Revision: 179786
>
> URL: http://llvm.org/viewvc/llvm-project?rev=179786&view=rev
> Log:
> In the function InstCombiner::visitExtractElementInst() removed the
> limitation that extract is promoted over a cast only if the cast has only
> one use.
>
>
> Added:
>     llvm/trunk/test/Transforms/InstCombine/vec_extract_2elts.ll
> Modified:
>     llvm/trunk/lib/Transforms/InstCombine/InstCombineVectorOps.cpp
>
> Modified: llvm/trunk/lib/Transforms/InstCombine/InstCombineVectorOps.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/InstCombine/InstCombineVectorOps.cpp?rev=179786&r1=179785&r2=179786&view=diff
>
> ==============================================================================
> --- llvm/trunk/lib/Transforms/InstCombine/InstCombineVectorOps.cpp
> (original)
> +++ llvm/trunk/lib/Transforms/InstCombine/InstCombineVectorOps.cpp Thu Apr
> 18 14:56:44 2013
> @@ -278,10 +278,10 @@ Instruction *InstCombiner::visitExtractE
>      } else if (CastInst *CI = dyn_cast<CastInst>(I)) {
>        // Canonicalize extractelement(cast) -> cast(extractelement)
>        // bitcasts can change the number of vector elements and they cost
> nothing
> -      if (CI->hasOneUse() && EI.hasOneUse() &&
> -          (CI->getOpcode() != Instruction::BitCast)) {
> -        Value *EE = Builder->CreateExtractElement(CI->getOperand(0),
> -                                                  EI.getIndexOperand());
> +      if (CI->hasOneUse() && (CI->getOpcode() != Instruction::BitCast)) {
> +        Value *EE = InsertNewInstWith(
> +                 ExtractElementInst::Create(CI->getOperand(0),
> EI.getIndexOperand()),
> +          *CI);
>          return CastInst::Create(CI->getOpcode(), EE, EI.getType());
>        }
>      }
>
> Added: llvm/trunk/test/Transforms/InstCombine/vec_extract_2elts.ll
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/vec_extract_2elts.ll?rev=179786&view=auto
>
> ==============================================================================
> --- llvm/trunk/test/Transforms/InstCombine/vec_extract_2elts.ll (added)
> +++ llvm/trunk/test/Transforms/InstCombine/vec_extract_2elts.ll Thu Apr 18
> 14:56:44 2013
> @@ -0,0 +1,12 @@
> +; RUN: opt < %s -instcombine -S | FileCheck %s
> +
> +define void @test(<4 x i32> %v, i64 *%r1, i64 *%r2) {
> +;CHECK: %1 = extractelement <4 x i32> %v, i32 0
> +;CHECK: %2 = zext i32 %1 to i64
> +        %1 = zext <4 x i32> %v to <4 x i64>
> +        %2 = extractelement <4 x i64> %1, i32 0
> +        store i64 %2, i64 *%r1
> +        store i64 %2, i64 *%r2
> +        ret void
> +}
> +
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20130422/f46acf3b/attachment.html>


More information about the llvm-commits mailing list