1 ; RUN: opt < %s -passes=indvars -S | FileCheck %s
3 target triple = "nvptx64-unknown-unknown"
5 ; For the nvptx64 architecture, the cost of an arithmetic instruction on a
6 ; 64-bit integer is twice as expensive as that on a 32-bit integer, because the
7 ; hardware needs to simulate a 64-bit integer using two 32-bit integers.
8 ; Therefore, in this particular architecture, we should not widen induction
9 ; variables to 64-bit integers even though i64 is a legal type in the 64-bit
12 define void @indvar_32_bit(i32 %n, ptr nocapture %output) {
13 ; CHECK-LABEL: @indvar_32_bit
15 %cmp5 = icmp sgt i32 %n, 0
16 br i1 %cmp5, label %for.body.preheader, label %for.end
18 for.body.preheader: ; preds = %entry
21 for.body: ; preds = %for.body.preheader, %for.body
22 %i.06 = phi i32 [ 0, %for.body.preheader ], [ %add, %for.body ]
24 %mul = mul nsw i32 %i.06, %i.06
25 %0 = sext i32 %i.06 to i64
26 %arrayidx = getelementptr inbounds i32, ptr %output, i64 %0
27 store i32 %mul, ptr %arrayidx, align 4
28 %add = add nsw i32 %i.06, 3
29 %cmp = icmp slt i32 %add, %n
30 br i1 %cmp, label %for.body, label %for.end.loopexit
32 for.end.loopexit: ; preds = %for.body
35 for.end: ; preds = %for.end.loopexit, %entry