1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc < %s | FileCheck %s
4 target datalayout = "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64"
5 target triple = "thumbv6m-arm-none-eabi"
7 ; From https://reviews.llvm.org/D62266
8 ; This used to cause an endless loop in DAGCombine,
9 ; since we were hoisting two binops with constants, one constant being opaque,
10 ; which is why they weren't getting constant folded.
12 @a = dso_local local_unnamed_addr global i32 0, align 4
13 @b = dso_local local_unnamed_addr global i32 0, align 4
15 ; Function Attrs: minsize nounwind optsize
16 define dso_local i32 @c() local_unnamed_addr #0 {
18 ; CHECK: @ %bb.0: @ %entry
19 ; CHECK-NEXT: .save {r4, lr}
20 ; CHECK-NEXT: push {r4, lr}
21 ; CHECK-NEXT: ldr r0, .LCPI0_0
22 ; CHECK-NEXT: ldr r0, [r0]
23 ; CHECK-NEXT: ldr r4, .LCPI0_1
24 ; CHECK-NEXT: subs r0, r4, r0
25 ; CHECK-NEXT: adds r0, r0, #1
27 ; CHECK-NEXT: ldr r0, .LCPI0_2
28 ; CHECK-NEXT: ldr r0, [r0]
29 ; CHECK-NEXT: cmp r0, r4
30 ; CHECK-NEXT: ble .LBB0_2
31 ; CHECK-NEXT: @ %bb.1: @ %if.then
33 ; CHECK-NEXT: .LBB0_2: @ %if.end
34 ; CHECK-NEXT: pop {r4, pc}
35 ; CHECK-NEXT: .p2align 2
36 ; CHECK-NEXT: @ %bb.3:
37 ; CHECK-NEXT: .LCPI0_0:
39 ; CHECK-NEXT: .LCPI0_1:
40 ; CHECK-NEXT: .long 1999 @ 0x7cf
41 ; CHECK-NEXT: .LCPI0_2:
44 %0 = load i32, i32* @a, align 4
45 %sub = sub nsw i32 2000, %0
46 %call = tail call i32 bitcast (i32 (...)* @d to i32 (i32)*)(i32 %sub) #2
47 %1 = load i32, i32* @b, align 4
48 %cmp = icmp sgt i32 %1, 1999
49 br i1 %cmp, label %if.then, label %if.end
51 if.then: ; preds = %entry
52 %call1 = tail call i32 bitcast (i32 (...)* @e to i32 ()*)() #2
55 if.end: ; preds = %if.then, %entry
59 declare dso_local i32 @d(...) local_unnamed_addr #1
60 declare dso_local i32 @e(...) local_unnamed_addr #1