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

            Bug ID: 38988
           Summary: Failure to thread extractelement through phi w/undef
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Scalar Optimizations
          Assignee: unassignedb...@nondot.org
          Reporter: listm...@philipreames.com
                CC: llvm-bugs@lists.llvm.org

$cat test.ll

define i32 @test(i1 %c, i32* nocapture readonly %p) {
  br i1 %c, label %cond.load, label %else

cond.load:                                        ; preds = %0
  %1 = load i32, i32* %p, align 4
  %2 = insertelement <1 x i32> undef, i32 %1, i32 0
  br label %else

else:                                             ; preds = %0, %cond.load
  %res.phi.select = phi <1 x i32> [ %2, %cond.load ], [ undef, %0 ]
  %3 = extractelement <1 x i32> %res.phi.select, i32 0
  ret i32 %3
}

$opt -O3 test.ll -S
(same as input)

We should be producing:
define i32 @test(i1 %c, i32* nocapture readonly %p) {
  br i1 %c, label %cond.load, label %else

cond.load:
  %1 = load i32, i32* %p, align 4
  br label %else

else:
  %ret = phi i32 [%1, %cond.load], [undef, %0]
  ret i32 %ret
}

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

Reply via email to