[PATCH] D99674: [InstCombine] Conditionally fold select i1 into and/or

Bjorn Pettersson via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Apr 7 04:38:19 PDT 2021


bjope added a comment.

Here is a reduced reproducer that goes into infinite loop with this patch:

  ; RUN: opt < %s -instcombine -S -o /dev/null
  
  ; This test case end up in an infinite loop with:
  ;    commit 5207cde5cb4147155c469e1861427ea9d569bd5a
  ;    Date:   Sun Apr 4 13:35:33 2021 +0900
  ;
  ;        [InstCombine] Conditionally fold select i1 into and/or
  
  define dso_local void @main(i16* %in, i32* %out, i32 %a) local_unnamed_addr {
  entry:
    %0 = load i16, i16* %in, align 1
    %conv456 = sext i16 %0 to i32
    %cmp468 = icmp sgt i16 %0, 0
    %broadcast.splatinsert2007 = insertelement <4 x i1> poison, i1 %cmp468, i32 0
    %broadcast.splat2008 = shufflevector <4 x i1> %broadcast.splatinsert2007, <4 x i1> poison, <4 x i32> zeroinitializer
    %broadcast.splatinsert2009 = insertelement <4 x i32> poison, i32 %conv456, i32 0
    %broadcast.splat2010 = shufflevector <4 x i32> %broadcast.splatinsert2009, <4 x i32> poison, <4 x i32> zeroinitializer
    %broadcast.splatinsert2005 = insertelement <4 x i32> poison, i32 %a, i32 0
    %broadcast.splat2006 = shufflevector <4 x i32> %broadcast.splatinsert2005, <4 x i32> poison, <4 x i32> zeroinitializer
    %1 = add <4 x i32> %broadcast.splat2006, <i32 1, i32 1, i32 1, i32 1>
    %2 = select <4 x i1> zeroinitializer, <4 x i32> zeroinitializer, <4 x i32> %1
    %3 = icmp slt <4 x i32> %2, zeroinitializer
    %4 = and <4 x i1> %broadcast.splat2008, %3
    %5 = add nsw <4 x i32> %2, <i32 2147483647, i32 2147483647, i32 2147483647, i32 2147483647>
    %6 = icmp slt <4 x i32> %5, %broadcast.splat2010
    %7 = select <4 x i1> %4, <4 x i1> %6, <4 x i1> zeroinitializer
    %8 = sub nsw <4 x i32> %broadcast.splat2010, %2
    %9 = select <4 x i1> zeroinitializer, <4 x i32> zeroinitializer, <4 x i32> %8
    %10 = xor <4 x i1> %7, <i1 true, i1 true, i1 true, i1 true>
    %predphi = select <4 x i1> %10, <4 x i32> %9, <4 x i32> zeroinitializer
    %11 = extractelement <4 x i32> %predphi, i32 1
    store i32 %11, i32* %out, align 1
    ret void
  }


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99674



More information about the llvm-commits mailing list