brintos

brintos / llvm-project-archived public Read only

0
0
Text · 6.0 KiB · 6bcd2f0 Raw
172 lines · plain
1; RUN: llc -O3 -mtriple arm64-apple-ios3 -aarch64-enable-gep-opt=false %s -o - | FileCheck %s2; <rdar://problem/13621857>3 4@block = common global ptr null, align 85 6define i32 @fct(i32 %i1, i32 %i2) {7; CHECK: @fct8; Sign extension is used more than once, thus it should not be folded.9; CodeGenPrepare is not sharing sext across uses, thus this is folded because10; of that.11; _CHECK-NOT: , sxtw]12entry:13  %idxprom = sext i32 %i1 to i6414  %0 = load ptr, ptr @block, align 815  %arrayidx = getelementptr inbounds i8, ptr %0, i64 %idxprom16  %1 = load i8, ptr %arrayidx, align 117  %idxprom1 = sext i32 %i2 to i6418  %arrayidx2 = getelementptr inbounds i8, ptr %0, i64 %idxprom119  %2 = load i8, ptr %arrayidx2, align 120  %cmp = icmp eq i8 %1, %221  br i1 %cmp, label %if.end, label %if.then22 23if.then:                                          ; preds = %entry24  %cmp7 = icmp ugt i8 %1, %225  %conv8 = zext i1 %cmp7 to i3226  br label %return27 28if.end:                                           ; preds = %entry29  %inc = add nsw i32 %i1, 130  %inc9 = add nsw i32 %i2, 131  %idxprom10 = sext i32 %inc to i6432  %arrayidx11 = getelementptr inbounds i8, ptr %0, i64 %idxprom1033  %3 = load i8, ptr %arrayidx11, align 134  %idxprom12 = sext i32 %inc9 to i6435  %arrayidx13 = getelementptr inbounds i8, ptr %0, i64 %idxprom1236  %4 = load i8, ptr %arrayidx13, align 137  %cmp16 = icmp eq i8 %3, %438  br i1 %cmp16, label %if.end23, label %if.then1839 40if.then18:                                        ; preds = %if.end41  %cmp21 = icmp ugt i8 %3, %442  %conv22 = zext i1 %cmp21 to i3243  br label %return44 45if.end23:                                         ; preds = %if.end46  %inc24 = add nsw i32 %i1, 247  %inc25 = add nsw i32 %i2, 248  %idxprom26 = sext i32 %inc24 to i6449  %arrayidx27 = getelementptr inbounds i8, ptr %0, i64 %idxprom2650  %5 = load i8, ptr %arrayidx27, align 151  %idxprom28 = sext i32 %inc25 to i6452  %arrayidx29 = getelementptr inbounds i8, ptr %0, i64 %idxprom2853  %6 = load i8, ptr %arrayidx29, align 154  %cmp32 = icmp eq i8 %5, %655  br i1 %cmp32, label %return, label %if.then3456 57if.then34:                                        ; preds = %if.end2358  %cmp37 = icmp ugt i8 %5, %659  %conv38 = zext i1 %cmp37 to i3260  br label %return61 62return:                                           ; preds = %if.end23, %if.then34, %if.then18, %if.then63  %retval.0 = phi i32 [ %conv8, %if.then ], [ %conv22, %if.then18 ], [ %conv38, %if.then34 ], [ 1, %if.end23 ]64  ret i32 %retval.065}66 67define i32 @fct1(i32 %i1, i32 %i2) optsize {68; CHECK: @fct169; Addressing are folded when optimizing for code size.70; CHECK: , sxtw]71; CHECK: , sxtw]72entry:73  %idxprom = sext i32 %i1 to i6474  %0 = load ptr, ptr @block, align 875  %arrayidx = getelementptr inbounds i8, ptr %0, i64 %idxprom76  %1 = load i8, ptr %arrayidx, align 177  %idxprom1 = sext i32 %i2 to i6478  %arrayidx2 = getelementptr inbounds i8, ptr %0, i64 %idxprom179  %2 = load i8, ptr %arrayidx2, align 180  %cmp = icmp eq i8 %1, %281  br i1 %cmp, label %if.end, label %if.then82 83if.then:                                          ; preds = %entry84  %cmp7 = icmp ugt i8 %1, %285  %conv8 = zext i1 %cmp7 to i3286  br label %return87 88if.end:                                           ; preds = %entry89  %inc = add nsw i32 %i1, 190  %inc9 = add nsw i32 %i2, 191  %idxprom10 = sext i32 %inc to i6492  %arrayidx11 = getelementptr inbounds i8, ptr %0, i64 %idxprom1093  %3 = load i8, ptr %arrayidx11, align 194  %idxprom12 = sext i32 %inc9 to i6495  %arrayidx13 = getelementptr inbounds i8, ptr %0, i64 %idxprom1296  %4 = load i8, ptr %arrayidx13, align 197  %cmp16 = icmp eq i8 %3, %498  br i1 %cmp16, label %if.end23, label %if.then1899 100if.then18:                                        ; preds = %if.end101  %cmp21 = icmp ugt i8 %3, %4102  %conv22 = zext i1 %cmp21 to i32103  br label %return104 105if.end23:                                         ; preds = %if.end106  %inc24 = add nsw i32 %i1, 2107  %inc25 = add nsw i32 %i2, 2108  %idxprom26 = sext i32 %inc24 to i64109  %arrayidx27 = getelementptr inbounds i8, ptr %0, i64 %idxprom26110  %5 = load i8, ptr %arrayidx27, align 1111  %idxprom28 = sext i32 %inc25 to i64112  %arrayidx29 = getelementptr inbounds i8, ptr %0, i64 %idxprom28113  %6 = load i8, ptr %arrayidx29, align 1114  %cmp32 = icmp eq i8 %5, %6115  br i1 %cmp32, label %return, label %if.then34116 117if.then34:                                        ; preds = %if.end23118  %cmp37 = icmp ugt i8 %5, %6119  %conv38 = zext i1 %cmp37 to i32120  br label %return121 122return:                                           ; preds = %if.end23, %if.then34, %if.then18, %if.then123  %retval.0 = phi i32 [ %conv8, %if.then ], [ %conv22, %if.then18 ], [ %conv38, %if.then34 ], [ 1, %if.end23 ]124  ret i32 %retval.0125}126 127; CHECK: @test128; CHECK: , uxtw #2]129define i32 @test(ptr %array, i8 zeroext %c, i32 %arg) {130entry:131  %conv = zext i8 %c to i32132  %add = sub i32 0, %arg133  %tobool = icmp eq i32 %conv, %add134  br i1 %tobool, label %if.end, label %if.then135 136if.then:                                          ; preds = %entry137  %idxprom = zext i8 %c to i64138  %arrayidx = getelementptr inbounds i32, ptr %array, i64 %idxprom139  %0 = load volatile i32, ptr %arrayidx, align 4140  %1 = load volatile i32, ptr %arrayidx, align 4141  %add3 = add nsw i32 %1, %0142  br label %if.end143 144if.end:                                           ; preds = %entry, %if.then145  %res.0 = phi i32 [ %add3, %if.then ], [ 0, %entry ]146  ret i32 %res.0147}148 149 150; CHECK: @test2151; CHECK: , uxtw #2]152; CHECK: , uxtw #2]153define i32 @test2(ptr %array, i8 zeroext %c, i32 %arg) optsize {154entry:155  %conv = zext i8 %c to i32156  %add = sub i32 0, %arg157  %tobool = icmp eq i32 %conv, %add158  br i1 %tobool, label %if.end, label %if.then159 160if.then:                                          ; preds = %entry161  %idxprom = zext i8 %c to i64162  %arrayidx = getelementptr inbounds i32, ptr %array, i64 %idxprom163  %0 = load volatile i32, ptr %arrayidx, align 4164  %1 = load volatile i32, ptr %arrayidx, align 4165  %add3 = add nsw i32 %1, %0166  br label %if.end167 168if.end:                                           ; preds = %entry, %if.then169  %res.0 = phi i32 [ %add3, %if.then ], [ 0, %entry ]170  ret i32 %res.0171}172