<commit_before>; RUN: llc < %s -march=x86-64 | FileCheck %s
; This test is to ensure the TwoAddrInstruction pass chooses the proper operands to
; merge and generates fewer mov insns.

@M = common global i32 0, align 4
@total = common global i32 0, align 4
@g = common global i32 0, align 4

; Function Attrs: nounwind uwtable
define void @foo() {
entry:
  %0 = load i32, i32* @M, align 4
  %cmp3 = icmp sgt i32 %0, 0
  br i1 %cmp3, label %for.body.lr.ph, label %for.end

for.body.lr.ph:                                   ; preds = %entry
  %total.promoted = load i32, i32* @total, align 4
  br label %for.body

; Check that only one mov will be generated in the kernel loop.
; CHECK-LABEL: foo:
; CHECK: [[LOOP1:^[a-zA-Z0-9_.]+]]: # %for.body
; CHECK-NOT: mov
; CHECK: movl {{.*}}, [[REG1:%[a-z0-9]+]]
; CHECK-NOT: mov
; CHECK: shrl $31, [[REG1]]
; CHECK-NOT: mov
; CHECK: jl [[LOOP1]]
for.body:                                         ; preds = %for.body.lr.ph, %for.body
  %add5 = phi i32 [ %total.promoted, %for.body.lr.ph ], [ %add, %for.body ]
  %i.04 = phi i32 [ 0, %for.body.lr.ph ], [ %inc, %for.body ]
  %div = sdiv i32 %i.04, 2
  %add = add nsw i32 %div, %add5
  %inc = add nuw nsw i32 %i.04, 1
  %cmp = icmp slt i32 %inc, %0
  br i1 %cmp, label %for.body, label %for.cond.for.end_crit_edge

for.cond.for.end_crit_edge:                       ; preds = %for.body
  store i32 %add, i32* @total, align 4
  br label %for.end

for.end:                                          ; preds = %for.cond.for.end_crit_edge, %entry
  ret void
}

; Function Attrs: nounwind uwtable
define void @goo() {
entry:
  %0 = load i32, i32* @M, align 4
  %cmp3 = icmp sgt i32 %0, 0
  br i1 %cmp3, label %for.body.lr.ph, label %for.end

for.body.lr.ph:                                   ; preds = %entry
  %total.promoted = load i32, i32* @total, align 4
  br label %for.body

; Check that only two mov will be generated in the kernel loop.
; CHECK-LABEL: goo:
; CHECK: [[LOOP2:^[a-zA-Z0-9_.]+]]: # %for.body
; CHECK-NOT: mov
; CHECK: movl {{.*}}, [[REG2:%[a-z0-9]+]]
; CHECK-NOT: mov
; CHECK: shrl $31, [[REG2]]
; CHECK-NOT: mov
; CHECK: movl {{.*}}, g(%rip)
; CHECK: jl [[LOOP2]]
for.body:                                         ; preds = %for.body.lr.ph, %for.body
  %add5 = phi i32 [ %total.promoted, %for.body.lr.ph ], [ %add, %for.body ]
  %i.04 = phi i32 [ 0, %for.body.lr.ph ], [ %inc, %for.body ]
  %div = sdiv i32 %i.04, 2
  %add = add nsw i32 %div, %add5
  store volatile i32 %add, i32* @g, align 4
  %inc = add nuw nsw i32 %i.04, 1
  %cmp = icmp slt i32 %inc, %0
  br i1 %cmp, label %for.body, label %for.cond.for.end_crit_edge

for.cond.for.end_crit_edge:                       ; preds = %for.body
  store i32 %add, i32* @total, align 4
  br label %for.end

for.end:                                          ; preds = %for.cond.for.end_crit_edge, %entry
  ret void
}
<commit_msg>Update twoaddr-coalesce-3.ll to run on darwin and linux machines:<commit_after>; RUN: llc < %s -march=x86-64 -relocation-model=pic | FileCheck %s
; This test is to ensure the TwoAddrInstruction pass chooses the proper operands to
; merge and generates fewer mov insns.

@M = common global i32 0, align 4
@total = common global i32 0, align 4
@g = common global i32 0, align 4

; Function Attrs: nounwind uwtable
define void @foo() {
entry:
  %0 = load i32, i32* @M, align 4
  %cmp3 = icmp sgt i32 %0, 0
  br i1 %cmp3, label %for.body.lr.ph, label %for.end

for.body.lr.ph:                                   ; preds = %entry
  %total.promoted = load i32, i32* @total, align 4
  br label %for.body

; Check that only one mov will be generated in the kernel loop.
; CHECK-LABEL: foo:
; CHECK: [[LOOP1:^[a-zA-Z0-9_.]+]]: {{#.*}} %for.body
; CHECK-NOT: mov
; CHECK: movl {{.*}}, [[REG1:%[a-z0-9]+]]
; CHECK-NOT: mov
; CHECK: shrl $31, [[REG1]]
; CHECK-NOT: mov
; CHECK: jl [[LOOP1]]
for.body:                                         ; preds = %for.body.lr.ph, %for.body
  %add5 = phi i32 [ %total.promoted, %for.body.lr.ph ], [ %add, %for.body ]
  %i.04 = phi i32 [ 0, %for.body.lr.ph ], [ %inc, %for.body ]
  %div = sdiv i32 %i.04, 2
  %add = add nsw i32 %div, %add5
  %inc = add nuw nsw i32 %i.04, 1
  %cmp = icmp slt i32 %inc, %0
  br i1 %cmp, label %for.body, label %for.cond.for.end_crit_edge

for.cond.for.end_crit_edge:                       ; preds = %for.body
  store i32 %add, i32* @total, align 4
  br label %for.end

for.end:                                          ; preds = %for.cond.for.end_crit_edge, %entry
  ret void
}

; Function Attrs: nounwind uwtable
define void @goo() {
entry:
  %0 = load i32, i32* @M, align 4
  %cmp3 = icmp sgt i32 %0, 0
  br i1 %cmp3, label %for.body.lr.ph, label %for.end

for.body.lr.ph:                                   ; preds = %entry
  %total.promoted = load i32, i32* @total, align 4
  br label %for.body

; Check that only two mov will be generated in the kernel loop.
; CHECK-LABEL: goo:
; CHECK: g@GOTPCREL(%rip), [[REG3:%[a-z0-0]+]]
; CHECK: [[LOOP2:^[a-zA-Z0-9_.]+]]: {{#.*}} %for.body
; CHECK-NOT: mov
; CHECK: movl {{.*}}, [[REG2:%[a-z0-9]+]]
; CHECK-NOT: mov
; CHECK: shrl $31, [[REG2]]
; CHECK-NOT: mov
; CHECK: movl {{.*}}, ([[REG3]])
; CHECK: jl [[LOOP2]]
for.body:                                         ; preds = %for.body.lr.ph, %for.body
  %add5 = phi i32 [ %total.promoted, %for.body.lr.ph ], [ %add, %for.body ]
  %i.04 = phi i32 [ 0, %for.body.lr.ph ], [ %inc, %for.body ]
  %div = sdiv i32 %i.04, 2
  %add = add nsw i32 %div, %add5
  store volatile i32 %add, i32* @g, align 4
  %inc = add nuw nsw i32 %i.04, 1
  %cmp = icmp slt i32 %inc, %0
  br i1 %cmp, label %for.body, label %for.cond.for.end_crit_edge

for.cond.for.end_crit_edge:                       ; preds = %for.body
  store i32 %add, i32* @total, align 4
  br label %for.end

for.end:                                          ; preds = %for.cond.for.end_crit_edge, %entry
  ret void
}

{'fraction_non_alphanumeric': 0.16395112016293278, 'fraction_numerical': 0.04735234215885947, 'mean_word_length': 2.2903405918481297, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 28, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '808048', 'n_tokens_mistral': 2469, 'n_tokens_neox': 2330, 'n_words': 696}