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
13 ; lahf/sahf instruction sequences. We make mem op volatile to prevent
14 ; their reordering to avoid spills.
19 %bval = load i8, i8* @b
20 %inc = add i8 %bval, 1
21 store volatile i8 %inc, i8* @b
22 %cval = load volatile i32, i32* @c
23 %inc1 = add nsw i32 %cval, 1
24 store volatile i32 %inc1, i32* @c
25 %aval = load volatile i8, i8* @a
26 %inc2 = add i8 %aval, 1
27 store volatile i8 %inc2, i8* @a
28 ; Copy flags produced by the incb of %inc1 to a register, need to save+restore
29 ; eax around it. The flags will be reused by %tobool.
33 ; CHECK: movl %eax, [[REG:%[a-z]+]]
35 %cmp = icmp eq i8 %aval, %bval
36 %conv5 = zext i1 %cmp to i8
37 store i8 %conv5, i8* @d
38 %tobool = icmp eq i32 %inc1, 0
39 ; We restore flags with an 'addb, sahf' sequence, need to save+restore eax
42 ; CHECK: movl [[REG]], %eax
43 ; CHECK: addb $127, %al
46 br i1 %tobool, label %if.end, label %if.then
49 %conv6 = sext i8 %inc to i32
50 %call = tail call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i32 0, i32 0), i32 %conv6)
57 declare i32 @printf(i8* nocapture readonly, ...)