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: unassignedb...@nondot.org
Reporter: reg...@cs.utah.edu
CC: htmldevelo...@gmail.com, llvm-bugs@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.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs