1 ; RUN: llc -o - %s | FileCheck %s
2 ; This tests for the problem originally reported in http://llvm.org/PR25951
3 target triple = "i686-unknown-linux-gnu"
5 @b = common global i8 0, align 1
6 @c = common global i32 0, align 4
7 @a = common global i8 0, align 1
8 @d = common global i8 0, align 1
9 @.str = private unnamed_addr constant [4 x i8] c"%d\0A\00", align 1
12 ; This tests whether eax is properly saved/restored around the lahf/sahf
13 ; instruction sequences.
16 %bval = load i8, i8* @b
17 %inc = add i8 %bval, 1
19 %cval = load i32, i32* @c
20 %inc1 = add nsw i32 %cval, 1
21 store i32 %inc1, i32* @c
22 %aval = load i8, i8* @a
23 %inc2 = add i8 %aval, 1
24 store i8 %inc2, i8* @a
25 ; Copy flags produced by the incb of %inc1 to a register, need to save+restore
26 ; eax around it. The flags will be reused by %tobool.
30 ; CHECK: movl %eax, [[REG:%[a-z]+]]
32 %cmp = icmp eq i8 %aval, %bval
33 %conv5 = zext i1 %cmp to i8
34 store i8 %conv5, i8* @d
35 %tobool = icmp eq i32 %inc1, 0
36 ; We restore flags with an 'addb, sahf' sequence, need to save+restore eax
39 ; CHECK: movl [[REG]], %eax
40 ; CHECK: addb $127, %al
43 br i1 %tobool, label %if.end, label %if.then
46 %conv6 = sext i8 %inc to i32
47 %call = tail call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i32 0, i32 0), i32 %conv6)
54 declare i32 @printf(i8* nocapture readonly, ...)