[PATCH] D93817: Update transformations to use poison for insertelement/shufflevector's placeholder value

Juneyoung Lee via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Dec 31 01:14:22 PST 2020


aqjune added a comment.

Running Alive2 finds one failure, which is fixed by updating the shufflevector semantics to return poison on undef/poison mask (D93818 <https://reviews.llvm.org/D93818>):

Transforms/InstCombine/shufflevector-div-rem-inseltpoison.ll

  ----------------------------------------                                           
  define <2 x float> @test_fdiv(float %a, float %b, i1 %cmp) {                       
  %0:                                                                                
    %splatinsert = insertelement <2 x float> poison, float %a, i32 0                 
    %denom = insertelement <2 x float> { 3.000000, poison }, float 1.000000, i32 1   
    %t1 = fdiv <2 x float> %splatinsert, %denom                                      
    %splat.op = shufflevector <2 x float> %t1, <2 x float> poison, 4294967295, 0     ; THIS BLOCKS POISON
    %t2 = select i1 %cmp, <2 x float> { 77.000000, 99.000000 }, <2 x float> %splat.op
    ret <2 x float> %t2                                                              
  }                                                                                  
  =>                                                                                 
  define <2 x float> @test_fdiv(float %a, float %b, i1 %cmp) {                       
  %0:                                                                                
    %1 = insertelement <2 x float> poison, float %a, i32 1                           
    %2 = fdiv <2 x float> %1, { undef, 3.000000 }                                    
    %t2 = select i1 %cmp, <2 x float> { 77.000000, 99.000000 }, <2 x float> %2       
    ret <2 x float> %t2                                                              
  }                                                                                  
  Transformation doesn't verify!                                                     
  ERROR: Target is more poisonous than source                                        

For the diffs, I checked that all of these are replacements of undef with poison, and there was no larger change.

After this patch, there are two places where undef still shows up as a placeholder from llvm tests: I couldn't find where they are coming from. :(
If someone points me where they're likely to appear, I'll fix these.

  $ ag "shufflevector <.*> .*, <.*> undef" | grep inseltpoison
  Transforms/InstCombine/X86/x86-pshufb-inseltpoison.ll
  
  $ ag "insertelement <.*> undef" | grep inseltpoison
  Transforms/InstCombine/AMDGPU/amdgcn-demanded-vector-elts-inseltpoison.ll


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D93817/new/

https://reviews.llvm.org/D93817



More information about the cfe-commits mailing list