-
Notifications
You must be signed in to change notification settings - Fork 15.4k
Closed
Description
consider this code:
extern void side_effect(void);
void f(int v0, int v1, int v2) {
if (v2 != v0) return;
if (v0 < v1) return;
if (v1 > v2) side_effect();
}we compile this to:
define void @f(i32 noundef %v0, i32 noundef %v1, i32 noundef %v2) {
entry:
%cmp.not = icmp eq i32 %v2, %v0
%cmp1 = icmp sge i32 %v0, %v1
%or.cond.not11 = and i1 %cmp1, %cmp.not
%cmp4 = icmp sgt i32 %v1, %v2
%or.cond10 = and i1 %cmp4, %or.cond.not11
br i1 %or.cond10, label %if.then5, label %if.end6
if.then5: ; preds = %entry
tail call void @side_effect() #2
br label %if.end6
if.end6: ; preds = %entry, %if.then5
ret void
}but that last conditional is always false: https://alive2.llvm.org/ce/z/LaLygS
this issue seems to involve both icmp eq and icmp ne:
https://gcc.godbolt.org/z/MK4xhMna6
https://alive2.llvm.org/ce/z/IXTadx