[llvm-bugs] [Bug 38988] New: Failure to thread extractelement through phi w/undef

via llvm-bugs llvm-bugs at lists.llvm.org
Tue Sep 18 15:00:13 PDT 2018


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: unassignedbugs at nondot.org
          Reporter: listmail at philipreames.com
                CC: llvm-bugs at 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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20180918/bdc177be/attachment.html>


More information about the llvm-bugs mailing list