blob: 3807424ece81ab66165bccceafc91dcca64c08aa [file] [log] [blame]
Tim Northover4a01ffb2017-05-02 22:45:19 +00001; RUN: llc -mtriple=arm %s -o - | FileCheck %s
2; RUN: llc -mtriple=thumbv7 %s -o - | FileCheck %s
3
4; We ended up feeding a deleted node back to TableGen when we converted "Off *
5; 410" into "(Off * 205) << 1", where the multiplication already existed in the
6; DAG.
7
8; CHECK-LABEL: addrmode_cse_mutation:
9; CHECK: {{mul|muls}} [[OFFSET:r[0-9]+]], {{r[0-9]+}}, {{r[0-9]+}}
10; CHECK: {{ldrb|ldrb.w}} {{r[0-9]+}}, [r0, [[OFFSET]], lsl #3]
11define i32 @addrmode_cse_mutation(i8* %base, i32 %count) {
12 %offset = mul i32 %count, 277288
13 %ptr = getelementptr i8, i8* %base, i32 %offset
14 %val = load volatile i8, i8* %ptr
15 %res = mul i32 %count, 34661
16 ret i32 %res
17}
Tim Northover761bcda2017-05-03 16:54:30 +000018
19; CHECK-LABEL: addrmode_cse_multi_use:
20; CHECK-NOT: {{ldrb|ldrb.w}} {{r[0-9]+}}, [{{r[0-9]+}}, {{r[0-9]+}}, lsl #3]
21define i32 @addrmode_cse_multi_use(i8* %base, i32 %count) {
22 %offset = mul i32 %count, 277288
23 %ptr = getelementptr i8, i8* %base, i32 %offset
24 %val = load volatile i8, i8* %ptr
25 %res = mul i32 %count, 34661
26 %res.1 = add i32 %res, %offset
27 ret i32 %res.1
28}