1 ; RUN: llc -regalloc=greedy -mtriple=x86_64-unknown-linux-gnu < %s -o - | FileCheck %s
3 ; The test is to check no redundent mov as follows will be generated in %while.body loop.
6 ; movl %edx, %eax ==> This movl can be promoted outside of loop.
13 ; CHECK: [[L0:.LBB0_[0-9]+]]: # %while.body
14 ; CHECK: movl %[[REGA:.*]], %[[REGB:.*]]
15 ; CHECK-NOT: movl %[[REGB]], %[[REGA]]
18 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
20 @b = common local_unnamed_addr global ptr null, align 8
21 @a = common local_unnamed_addr global i32 0, align 4
23 define i32 @foo() local_unnamed_addr {
25 %t0 = load ptr, ptr @b, align 8
26 %t1 = load i8, ptr %t0, align 1
27 %cmp4 = icmp eq i8 %t1, 0
28 %t2 = load i32, ptr @a, align 4
29 br i1 %cmp4, label %while.end, label %while.body.preheader
31 while.body.preheader: ; preds = %entry
34 while.body: ; preds = %while.body.preheader, %while.body
35 %t3 = phi i32 [ %add3, %while.body ], [ %t2, %while.body.preheader ]
36 %t4 = phi i8 [ %t5, %while.body ], [ %t1, %while.body.preheader ]
37 %conv = sext i8 %t4 to i32
38 %add = mul i32 %t3, 33
39 %add3 = add nsw i32 %add, %conv
40 store i32 %add3, ptr @a, align 4
41 %t5 = load i8, ptr %t0, align 1
42 %cmp = icmp eq i8 %t5, 0
43 br i1 %cmp, label %while.end.loopexit, label %while.body
45 while.end.loopexit: ; preds = %while.body
48 while.end: ; preds = %while.end.loopexit, %entry
49 %.lcssa = phi i32 [ %t2, %entry ], [ %add3, %while.end.loopexit ]