1 ; RUN: llc -march=hexagon < %s | FileCheck %s
3 ; DAG combiner folds sequences of shifts, which can sometimes obscure
4 ; optimization opportunities. For example
6 ; unsigned int c(unsigned int b, unsigned int *a) {
7 ; unsigned int bitidx = b >> 5;
12 ; (add x (shl (srl y 5) 2))
13 ; which is then folded into
14 ; (add x (and (srl y 3) 1FFFFFFC))
16 ; That results in a constant-extended and:
17 ; r0 = and(##536870908,lsr(r0,#3))
18 ; r0 = memw(r1+r0<<#0)
21 ; r0 = memw(r1+r0<<#2)
24 target triple = "hexagon"
27 ; CHECK: memw(r{{[0-9]+}}+r{{[0-9]}}<<#2)
28 define i32 @load_0(i32 %b, ptr nocapture readonly %a) #0 {
31 %arrayidx = getelementptr inbounds i32, ptr %a, i32 %shr
32 %0 = load i32, ptr %arrayidx, align 4
36 ; This would require r0<<#3, which is not legal.
38 ; CHECK: memw(r{{[0-9]+}}+r{{[0-9]}}<<#0)
39 define i32 @load_1(i32 %b, ptr nocapture readonly %a) #0 {
42 %arrayidx = getelementptr inbounds [3 x i32], ptr %a, i32 %shr, i32 0
43 %0 = load i32, ptr %arrayidx, align 4
47 ; CHECK-LABEL: store_0
48 ; CHECK: memw(r{{[0-9]+}}+r{{[0-9]}}<<#2)
49 define void @store_0(i32 %b, ptr nocapture %a, i32 %v) #1 {
52 %arrayidx = getelementptr inbounds i32, ptr %a, i32 %shr
53 store i32 %v, ptr %arrayidx, align 4
57 attributes #0 = { norecurse nounwind readonly "target-cpu"="hexagonv60" "target-features"="-hvx,-long-calls" }
58 attributes #1 = { norecurse nounwind "target-cpu"="hexagonv60" "target-features"="-hvx,-long-calls" }