https://bugs.llvm.org/show_bug.cgi?id=51092

            Bug ID: 51092
           Summary: Duplicate select instruction causing one use check
                    failure
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Scalar Optimizations
          Assignee: unassignedb...@nondot.org
          Reporter: llvm-...@redking.me.uk
                CC: lebedev...@gmail.com, llvm-bugs@lists.llvm.org,
                    nikita....@gmail.com, spatel+l...@rotateright.com

https://godbolt.org/z/4avqKsT4x

struct PayLoad
{
        unsigned short data[3];
};

void sort(PayLoad* pData, int lo, int hi, int ishi)
{
  if (ishi)
  {
    pData->data[hi]++;
  }
  else
  {
    pData->data[lo]++;
  }
}

%struct.PayLoad = type { [3 x i16] }

define void @_Z4sortP7PayLoadiii(%struct.PayLoad* nocapture %0, i32 %1, i32 %2,
i32 %3) {
  %5 = icmp eq i32 %3, 0
  %6 = sext i32 %1 to i64
  %7 = getelementptr inbounds %struct.PayLoad, %struct.PayLoad* %0, i64 0, i32
0, i64 %6
  %8 = sext i32 %2 to i64
  %9 = getelementptr inbounds %struct.PayLoad, %struct.PayLoad* %0, i64 0, i32
0, i64 %8
  %10 = select i1 %5, i16* %7, i16* %9
  %11 = select i1 %5, i16* %7, i16* %9
  %12 = load i16, i16* %10, align 2, !tbaa !3
  %13 = add i16 %12, 1
  store i16 %13, i16* %11, align 2, !tbaa !3
  ret void
}

I'm currently investigating supporting select(gep,gep) folding for geps with >
2 operands, but we fail the one use check on this reduced test case as we end
up with the same select instruction twice which never get merged.

Should these be merged or not?

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to