[PATCH] D40790: DAGCombiner bugfix in MergeStoresOfConstantsOrVecElts()

Sanjay Patel via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Dec 4 14:36:24 PST 2017


spatel added reviewers: niravd, efriedma.
spatel added a comment.

It's not clear to me what it takes to reveal the bug, but it shouldn't be (much?) more than a series of stores. Can you reduce the test further than this? Also, can FP constant stores have the same problem?

  @x = internal unnamed_addr global i16 1, align 2
  @y = internal unnamed_addr global [10 x [7 x i16]] zeroinitializer
  
  define signext i32 @bad_merge(i16* %x) {
    %ld = load i16, i16* @x, align 2
    %or = or i16 %ld, 32606
    store i16 %or, i16* @x, align 2
    store i16 -7, i16* getelementptr inbounds ([10 x [7 x i16]], [10 x [7 x i16]]* @y, i64 0, i64 0, i64 0), align 2
    store i16 -7, i16* getelementptr inbounds ([10 x [7 x i16]], [10 x [7 x i16]]* @y, i64 0, i64 0, i64 1), align 2
    store i16 -7, i16* getelementptr inbounds ([10 x [7 x i16]], [10 x [7 x i16]]* @y, i64 0, i64 0, i64 2), align 2
    store i16 -7, i16* getelementptr inbounds ([10 x [7 x i16]], [10 x [7 x i16]]* @y, i64 0, i64 0, i64 3), align 2
    store i16 -7, i16* getelementptr inbounds ([10 x [7 x i16]], [10 x [7 x i16]]* @y, i64 0, i64 0, i64 4), align 2
    store i16 -7, i16* getelementptr inbounds ([10 x [7 x i16]], [10 x [7 x i16]]* @y, i64 0, i64 0, i64 5), align 2
    store i16 -7, i16* getelementptr inbounds ([10 x [7 x i16]], [10 x [7 x i16]]* @y, i64 0, i64 0, i64 6), align 2
    store i16 -7, i16* getelementptr inbounds ([10 x [7 x i16]], [10 x [7 x i16]]* @y, i64 0, i64 1, i64 0), align 2
    store i16 -7, i16* getelementptr inbounds ([10 x [7 x i16]], [10 x [7 x i16]]* @y, i64 0, i64 1, i64 1), align 2
    store i16 -7, i16* getelementptr inbounds ([10 x [7 x i16]], [10 x [7 x i16]]* @y, i64 0, i64 1, i64 2), align 2
    store i16 -7, i16* getelementptr inbounds ([10 x [7 x i16]], [10 x [7 x i16]]* @y, i64 0, i64 1, i64 3), align 2
    store i16 -7, i16* getelementptr inbounds ([10 x [7 x i16]], [10 x [7 x i16]]* @y, i64 0, i64 1, i64 4), align 2
    store i16 -7, i16* getelementptr inbounds ([10 x [7 x i16]], [10 x [7 x i16]]* @y, i64 0, i64 1, i64 5), align 2
    store i16 -7, i16* getelementptr inbounds ([10 x [7 x i16]], [10 x [7 x i16]]* @y, i64 0, i64 1, i64 6), align 2
    store i16 -7, i16* getelementptr inbounds ([10 x [7 x i16]], [10 x [7 x i16]]* @y, i64 0, i64 2, i64 0), align 2
    store i16 -7, i16* getelementptr inbounds ([10 x [7 x i16]], [10 x [7 x i16]]* @y, i64 0, i64 2, i64 1), align 2
    store i16 -7, i16* getelementptr inbounds ([10 x [7 x i16]], [10 x [7 x i16]]* @y, i64 0, i64 2, i64 2), align 2
    store i16 -7, i16* getelementptr inbounds ([10 x [7 x i16]], [10 x [7 x i16]]* @y, i64 0, i64 2, i64 3), align 2
    store i16 -7, i16* getelementptr inbounds ([10 x [7 x i16]], [10 x [7 x i16]]* @y, i64 0, i64 2, i64 4), align 2
    store i16 -7, i16* getelementptr inbounds ([10 x [7 x i16]], [10 x [7 x i16]]* @y, i64 0, i64 2, i64 5), align 2
    store i16 -7, i16* getelementptr inbounds ([10 x [7 x i16]], [10 x [7 x i16]]* @y, i64 0, i64 2, i64 6), align 2
    store i16 -7, i16* getelementptr inbounds ([10 x [7 x i16]], [10 x [7 x i16]]* @y, i64 0, i64 3, i64 0), align 2
    store i16 -7, i16* getelementptr inbounds ([10 x [7 x i16]], [10 x [7 x i16]]* @y, i64 0, i64 3, i64 1), align 2
    store i16 -7, i16* getelementptr inbounds ([10 x [7 x i16]], [10 x [7 x i16]]* @y, i64 0, i64 3, i64 2), align 2
    store i16 -7, i16* getelementptr inbounds ([10 x [7 x i16]], [10 x [7 x i16]]* @y, i64 0, i64 3, i64 3), align 2
    store i16 -7, i16* getelementptr inbounds ([10 x [7 x i16]], [10 x [7 x i16]]* @y, i64 0, i64 3, i64 4), align 2
    store i16 -7, i16* getelementptr inbounds ([10 x [7 x i16]], [10 x [7 x i16]]* @y, i64 0, i64 3, i64 5), align 2
    store i16 -7, i16* getelementptr inbounds ([10 x [7 x i16]], [10 x [7 x i16]]* @y, i64 0, i64 3, i64 6), align 2
    store i16 -7, i16* getelementptr inbounds ([10 x [7 x i16]], [10 x [7 x i16]]* @y, i64 0, i64 4, i64 0), align 2
    store i16 -7, i16* getelementptr inbounds ([10 x [7 x i16]], [10 x [7 x i16]]* @y, i64 0, i64 4, i64 1), align 2
    store i16 -7, i16* getelementptr inbounds ([10 x [7 x i16]], [10 x [7 x i16]]* @y, i64 0, i64 4, i64 2), align 2
    store i16 -7, i16* getelementptr inbounds ([10 x [7 x i16]], [10 x [7 x i16]]* @y, i64 0, i64 4, i64 3), align 2
    store i16 -7, i16* getelementptr inbounds ([10 x [7 x i16]], [10 x [7 x i16]]* @y, i64 0, i64 4, i64 4), align 2
    store i16 -7, i16* getelementptr inbounds ([10 x [7 x i16]], [10 x [7 x i16]]* @y, i64 0, i64 4, i64 5), align 2
    store i16 -7, i16* getelementptr inbounds ([10 x [7 x i16]], [10 x [7 x i16]]* @y, i64 0, i64 4, i64 6), align 2
    store i16 -7, i16* getelementptr inbounds ([10 x [7 x i16]], [10 x [7 x i16]]* @y, i64 0, i64 5, i64 0), align 2
    store i16 -7, i16* getelementptr inbounds ([10 x [7 x i16]], [10 x [7 x i16]]* @y, i64 0, i64 5, i64 1), align 2
    store i16 -7, i16* getelementptr inbounds ([10 x [7 x i16]], [10 x [7 x i16]]* @y, i64 0, i64 5, i64 2), align 2
    store i16 -7, i16* getelementptr inbounds ([10 x [7 x i16]], [10 x [7 x i16]]* @y, i64 0, i64 5, i64 3), align 2
    store i16 -7, i16* getelementptr inbounds ([10 x [7 x i16]], [10 x [7 x i16]]* @y, i64 0, i64 5, i64 4), align 2
    store i16 -7, i16* getelementptr inbounds ([10 x [7 x i16]], [10 x [7 x i16]]* @y, i64 0, i64 5, i64 5), align 2
    store i16 -7, i16* getelementptr inbounds ([10 x [7 x i16]], [10 x [7 x i16]]* @y, i64 0, i64 5, i64 6), align 2
    store i16 -7, i16* getelementptr inbounds ([10 x [7 x i16]], [10 x [7 x i16]]* @y, i64 0, i64 6, i64 0), align 2
    store i16 -7, i16* getelementptr inbounds ([10 x [7 x i16]], [10 x [7 x i16]]* @y, i64 0, i64 6, i64 1), align 2
    store i16 -7, i16* getelementptr inbounds ([10 x [7 x i16]], [10 x [7 x i16]]* @y, i64 0, i64 6, i64 2), align 2
    store i16 -7, i16* getelementptr inbounds ([10 x [7 x i16]], [10 x [7 x i16]]* @y, i64 0, i64 6, i64 3), align 2
    store i16 -7, i16* getelementptr inbounds ([10 x [7 x i16]], [10 x [7 x i16]]* @y, i64 0, i64 6, i64 4), align 2
    store i16 -7, i16* getelementptr inbounds ([10 x [7 x i16]], [10 x [7 x i16]]* @y, i64 0, i64 6, i64 5), align 2
    store i16 -7, i16* getelementptr inbounds ([10 x [7 x i16]], [10 x [7 x i16]]* @y, i64 0, i64 6, i64 6), align 2
    store i16 -7, i16* getelementptr inbounds ([10 x [7 x i16]], [10 x [7 x i16]]* @y, i64 0, i64 7, i64 0), align 2
    store i16 -7, i16* getelementptr inbounds ([10 x [7 x i16]], [10 x [7 x i16]]* @y, i64 0, i64 7, i64 1), align 2
    store i16 -7, i16* getelementptr inbounds ([10 x [7 x i16]], [10 x [7 x i16]]* @y, i64 0, i64 7, i64 2), align 2
    store i16 -7, i16* getelementptr inbounds ([10 x [7 x i16]], [10 x [7 x i16]]* @y, i64 0, i64 7, i64 3), align 2
    store i16 -7, i16* getelementptr inbounds ([10 x [7 x i16]], [10 x [7 x i16]]* @y, i64 0, i64 7, i64 4), align 2
    store i16 -7, i16* getelementptr inbounds ([10 x [7 x i16]], [10 x [7 x i16]]* @y, i64 0, i64 7, i64 5), align 2
    store i16 -7, i16* getelementptr inbounds ([10 x [7 x i16]], [10 x [7 x i16]]* @y, i64 0, i64 7, i64 6), align 2
    store i16 -7, i16* getelementptr inbounds ([10 x [7 x i16]], [10 x [7 x i16]]* @y, i64 0, i64 8, i64 0), align 2
    store i16 -7, i16* getelementptr inbounds ([10 x [7 x i16]], [10 x [7 x i16]]* @y, i64 0, i64 8, i64 1), align 2
    store i16 -7, i16* getelementptr inbounds ([10 x [7 x i16]], [10 x [7 x i16]]* @y, i64 0, i64 8, i64 2), align 2
    store i16 -7, i16* getelementptr inbounds ([10 x [7 x i16]], [10 x [7 x i16]]* @y, i64 0, i64 8, i64 3), align 2
    store i16 -7, i16* getelementptr inbounds ([10 x [7 x i16]], [10 x [7 x i16]]* @y, i64 0, i64 8, i64 4), align 2
    store i16 -7, i16* getelementptr inbounds ([10 x [7 x i16]], [10 x [7 x i16]]* @y, i64 0, i64 8, i64 5), align 2
    store i16 -7, i16* getelementptr inbounds ([10 x [7 x i16]], [10 x [7 x i16]]* @y, i64 0, i64 8, i64 6), align 2
    store i16 -7, i16* getelementptr inbounds ([10 x [7 x i16]], [10 x [7 x i16]]* @y, i64 0, i64 9, i64 0), align 2
    store i16 -7, i16* getelementptr inbounds ([10 x [7 x i16]], [10 x [7 x i16]]* @y, i64 0, i64 9, i64 1), align 2
    store i16 -7, i16* getelementptr inbounds ([10 x [7 x i16]], [10 x [7 x i16]]* @y, i64 0, i64 9, i64 2), align 2
    store i16 -7, i16* getelementptr inbounds ([10 x [7 x i16]], [10 x [7 x i16]]* @y, i64 0, i64 9, i64 3), align 2
    store i16 -7, i16* getelementptr inbounds ([10 x [7 x i16]], [10 x [7 x i16]]* @y, i64 0, i64 9, i64 4), align 2
    store i16 -7, i16* getelementptr inbounds ([10 x [7 x i16]], [10 x [7 x i16]]* @y, i64 0, i64 9, i64 5), align 2
    store i16 -7, i16* getelementptr inbounds ([10 x [7 x i16]], [10 x [7 x i16]]* @y, i64 0, i64 9, i64 6), align 2
    ret i32 0
  }


https://reviews.llvm.org/D40790





More information about the llvm-commits mailing list