[llvm-bugs] [Bug 40768] New: it is not, in general, safe to speculatively execute a shift

via llvm-bugs llvm-bugs at lists.llvm.org
Mon Feb 18 15:46:39 PST 2019


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

            Bug ID: 40768
           Summary: it is not, in general, safe to speculatively execute a
                    shift
           Product: new-bugs
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: new bugs
          Assignee: unassignedbugs at nondot.org
          Reporter: regehr at cs.utah.edu
                CC: htmldeveloper at gmail.com, llvm-bugs at lists.llvm.org

The optimization below takes a function that is defined when argument %0 is
negative and turns it into a function that returns poison when argument %0 is
negative.

Many of the UB problems that we see in LLVM require us to answer difficult
semantic questions before they can be resolved, but this one doesn't seem like
that. Rather, it's a straightforward example of something that an LLVM pass
just cannot do.

*** IR Dump Before Simplify the CFG ***
; Function Attrs: nounwind uwtable
define internal fastcc i32 @f(i32) unnamed_addr #0 {
  %2 = icmp slt i32 %0, 0
  br i1 %2, label %6, label %3

; <label>:3:                                      ; preds = %1
  %4 = lshr i32 127, %0
  %5 = icmp slt i32 %4, 1
  br i1 %5, label %6, label %7

; <label>:6:                                      ; preds = %3, %1
  br label %7

; <label>:7:                                      ; preds = %3, %6
  %8 = phi i32 [ 1, %6 ], [ 0, %3 ]
  ret i32 %8
}
*** IR Dump After Simplify the CFG ***
; Function Attrs: nounwind uwtable
define internal fastcc i32 @f(i32) unnamed_addr #0 {
  %2 = icmp slt i32 %0, 0
  %3 = lshr i32 127, %0
  %4 = icmp slt i32 %3, 1
  %5 = or i1 %2, %4
  %6 = select i1 %5, i32 1, i32 0
  ret i32 %6
}

-- 
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/20190218/9ccfe346/attachment.html>


More information about the llvm-bugs mailing list