; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py ; RUN: llc < %s -mtriple=riscv64 | FileCheck %s ; Make sure we don't emit a pair of shift for the zext in the preheader. We ; can tell that bit 31 is 0 in the preheader and rely on %n already being ; sign extended without adding zeros explicitly. define void @test1(ptr nocapture noundef %a, i32 noundef signext %n) { ; CHECK-LABEL: test1: ; CHECK: # %bb.0: # %entry ; CHECK-NEXT: blez a1, .LBB0_2 ; CHECK-NEXT: .LBB0_1: # %for.body ; CHECK-NEXT: # =>This Inner Loop Header: Depth=1 ; CHECK-NEXT: lw a2, 0(a0) ; CHECK-NEXT: addiw a2, a2, 4 ; CHECK-NEXT: sw a2, 0(a0) ; CHECK-NEXT: addi a1, a1, -1 ; CHECK-NEXT: addi a0, a0, 4 ; CHECK-NEXT: bnez a1, .LBB0_1 ; CHECK-NEXT: .LBB0_2: # %for.cond.cleanup ; CHECK-NEXT: ret entry: %cmp3 = icmp sgt i32 %n, 0 br i1 %cmp3, label %for.body.preheader, label %for.cond.cleanup for.body.preheader: ; preds = %entry %wide.trip.count = zext i32 %n to i64 br label %for.body for.cond.cleanup: ; preds = %for.body, %entry ret void for.body: ; preds = %for.body.preheader, %for.body %indvars.iv = phi i64 [ 0, %for.body.preheader ], [ %indvars.iv.next, %for.body ] %arrayidx = getelementptr inbounds i32, ptr %a, i64 %indvars.iv %0 = load i32, ptr %arrayidx, align 4 %add = add nsw i32 %0, 4 store i32 %add, ptr %arrayidx, align 4 %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1 %exitcond.not = icmp eq i64 %indvars.iv.next, %wide.trip.count br i1 %exitcond.not, label %for.cond.cleanup, label %for.body }