Souper says:
; Function: fn1
%0:i32 = var
%1:i32 = lshr 1:i32, %0
%2:i1 = slt %1, 0:i32
cand %2 0:i1
COMMAND: /home/regehr/souper/build/souper -stp-path=/usr/local/bin/stp reduce_140/foo.bc
LLVM says:
define void @fn1() #0 {
entry:
%0 = load i32* @a, align 4, !tbaa !1
%shr = lshr i32 1, %0
store i32 %shr, i32* @c, align 4, !tbaa !1
%cmp = icmp slt i32 %shr, 0
br i1 %cmp, label %lor.end, label %lor.rhs
lor.rhs: ; preds = %entry
store i32 0, i32* @b, align 4, !tbaa !1
br label %lor.end
lor.end: ; preds = %lor.rhs, %entry
ret void
}
COMMAND: /home/regehr/souper/third_party/llvm/Debug/bin/clang -c -w -emit-llvm -O3 reduce_140/foo.c -o reduce_140/foo.bc
C source code:
int a, b, c;
void fn1() {
c = 1 >> a;
0 > c || (b = 0);
}
x86-64 from LLVM:
fn1: # @fn1
movb a(%rip), %cl
movl $1, %eax
shrl %cl, %eax
testl %eax, %eax
movl %eax, c(%rip)
js .LBB0_2
movl $0, b(%rip)
.LBB0_2: # %lor.end
retq
COMMAND: /home/regehr/souper/third_party/llvm/Debug/bin/clang -w -O3 reduce_140/foo.c -S -o -
x86-64 from GCC:
fn1:
movl a(%rip), %ecx
movl $1, %eax
sarl %cl, %eax
testl %eax, %eax
movl %eax, c(%rip)
js .L1
movl $0, b(%rip)
.L1:
rep ret
COMMAND: gcc -w -O3 reduce_140/foo.c -S -o -