Hi all:
I write C code like this:
```
for (int i =0; i< 128; i++) {
printf("hello");
}
```
I use this command to compile the above code.
``
clang -Xclang -disable-O0-optnone -O0 -emit-llvm -S main.c
opt -O2 --print-after-all main.ll -S -o main.mid.ll
``
And I find the LLVM IR have this changed after instCombine optimization.
```
*** IR Dump After Dead Argument Elimination ***
; Function Attrs: noinline nounwind uwtable
define dso_local i32 @main(i32 %argc, i8** %argv) local_unnamed_addr #0 {
entry:
br label %for.cond
for.cond: ; preds = %for.body, %entry
%i.0 = phi i32 [ 0, %entry ], [ %inc, %for.body ]
%cmp = icmp sle i32 %i.0, 128
br i1 %cmp, label %for.body, label %for.end
for.body: ; preds = %for.cond
%call = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x
i8]* @.str, i64 0, i64 0))
%inc = add nsw i32 %i.0, 1
br label %for.cond
for.end: ; preds = %for.cond
ret i32 0
}
*** IR Dump After Combine redundant instructions ***
; Function Attrs: noinline nounwind uwtable
define dso_local i32 @main(i32 %argc, i8** %argv) local_unnamed_addr #0 {
entry:
br label %for.cond
for.cond: ; preds = %for.body, %entry
%i.0 = phi i32 [ 0, %entry ], [ %inc, %for.body ]
%cmp = icmp ult i32 %i.0, 129
br i1 %cmp, label %for.body, label %for.end
for.body: ; preds = %for.cond
%call = call i32 (i8*, ...) @printf(i8* nonnull dereferenceable(1)
getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%inc = add nuw nsw i32 %i.0, 1
br label %for.cond
for.end: ; preds = %for.cond
ret i32 0
}
ยทยทยท
I find the value 128 chaned to 129. So I want to know what's the purpose to
changed the form?Can you give some example?
Thanks
Rock
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://lists.llvm.org/pipermail/llvm-dev/attachments/20210810/7547039f/attachment.html>