1 # RUN: llc -run-pass=peephole-opt %s -o - | FileCheck %s
3 # Here we check that the peephole cmp rewrite is not triggered, because
4 # there is store instruction between the tMUL and tCMP, i.e. there are
5 # no constants to reorder.
8 ; ModuleID = 'cmp2-peephole-thumb.ll'
9 source_filename = "<stdin>"
10 target datalayout = "e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64"
11 target triple = "thumb-none--eabi"
13 define i32 @g(i32 %a, i32 %b) {
15 %retval = alloca i32, align 4
16 %mul = alloca i32, align 4
17 %mul1 = mul nsw i32 %a, %b
18 store i32 %mul1, i32* %mul, align 4
19 %0 = load i32, i32* %mul, align 4
20 %cmp = icmp sle i32 %0, 0
21 br i1 %cmp, label %if.then, label %if.end
23 if.then: ; preds = %entry
24 store i32 42, i32* %retval, align 4
27 if.end: ; preds = %entry
28 store i32 1, i32* %retval, align 4
31 return: ; preds = %if.end, %if.then
32 %1 = load i32, i32* %retval, align 4
39 # CHECK-LABEL: name: g
41 exposesReturnsTwice: false
43 regBankSelected: false
45 tracksRegLiveness: true
47 - { id: 0, class: tgpr }
48 - { id: 1, class: tgpr }
49 - { id: 2, class: tgpr }
50 - { id: 3, class: tgpr }
51 - { id: 4, class: tgpr }
52 - { id: 5, class: tgpr }
54 - { reg: '$r0', virtual-reg: '%0' }
55 - { reg: '$r1', virtual-reg: '%1' }
57 isFrameAddressTaken: false
58 isReturnAddressTaken: false
67 hasOpaqueSPAdjustment: false
69 hasMustTailInVarArgFunc: false
71 - { id: 0, name: retval, offset: 0, size: 4, alignment: 4, local-offset: -4 }
72 - { id: 1, name: mul, offset: 0, size: 4, alignment: 4, local-offset: -8 }
83 %2, $cpsr = tMUL %0, %1, 14, $noreg
84 tSTRspi %2, %stack.1.mul, 0, 14, $noreg :: (store 4 into %ir.mul)
85 tCMPi8 %2, 0, 14, $noreg, implicit-def $cpsr
86 tBcc %bb.2.if.end, 12, $cpsr
87 tB %bb.1.if.then, 14, $noreg
90 %4, $cpsr = tMOVi8 42, 14, $noreg
91 tSTRspi killed %4, %stack.0.retval, 0, 14, $noreg :: (store 4 into %ir.retval)
92 tB %bb.3.return, 14, $noreg
95 %3, $cpsr = tMOVi8 1, 14, $noreg
96 tSTRspi killed %3, %stack.0.retval, 0, 14, $noreg :: (store 4 into %ir.retval)
99 %5 = tLDRspi %stack.0.retval, 0, 14, $noreg :: (dereferenceable load 4 from %ir.retval)
101 tBX_RET 14, $noreg, implicit $r0