Digvijay Gour via llvm-dev
2019-Apr-07 18:17 UTC
[llvm-dev] GVN-Hoist test case not working
Hello, I was trying a basic example on LLVM GVN Hoist and output differs from what I expect. Am I missing something ? *Code* : int main() { int x = 7; int a = 0; if(a == 7){ x = 1; a = 8 * x; } else { x = 1; a = 2 * x; } return 0; } *Commands* : clang-8 -O0 -S -emit-llvm test.c opt-8 -gvn-hoist -S < test.ll *Output :* ; ModuleID = '<stdin>' source_filename = "test.c" target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" target triple = "x86_64-pc-linux-gnu" ; Function Attrs: noinline nounwind optnone uwtable define dso_local i32 @main() #0 { %1 = alloca i32, align 4 %2 = alloca i32, align 4 %3 = alloca i32, align 4 store i32 0, i32* %1, align 4 store i32 7, i32* %2, align 4 store i32 0, i32* %3, align 4 %4 = load i32, i32* %3, align 4 %5 = icmp eq i32 %4, 7 br i1 %5, label %6, label %9 ; <label>:6: ; preds = %0 store i32 1, i32* %2, align 4 %7 = load i32, i32* %2, align 4 %8 = mul nsw i32 8, %7 store i32 %8, i32* %3, align 4 br label %12 ; <label>:9: ; preds = %0 store i32 1, i32* %2, align 4 %10 = load i32, i32* %2, align 4 %11 = mul nsw i32 2, %10 store i32 %11, i32* %3, align 4 br label %12 ; <label>:12: ; preds = %9, %6 ret i32 0 } attributes #0 = { noinline nounwind optnone uwtable "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "less-precise-fpmad"="false" "min-legal-vector-width"="0" "no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf" "no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="false" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+fxsr,+mmx,+sse,+sse2,+x87" "unsafe-fp-math"="false" "use-soft-float"="false" } !llvm.module.flags = !{!0} !llvm.ident = !{!1} !0 = !{i32 1, !"wchar_size", i32 4} !1 = !{!"clang version 8.0.0-svn356034-1~exp1~20190313093039.54 (branches/release_80)"} Thank you, Digvijay -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20190407/5bc769cf/attachment.html>
Tim Northover via llvm-dev
2019-Apr-08 12:51 UTC
[llvm-dev] GVN-Hoist test case not working
On Mon, 8 Apr 2019 at 12:22, Digvijay Gour via llvm-dev <llvm-dev at lists.llvm.org> wrote:> I was trying a basic example on LLVM GVN Hoist and output differs from what I expect. Am I missing something ?At -O0 Clang usually attaches the "optnone" attribute to functions it generates, which disables all LLVM passes even if they get run. Try adding "-Xclang -disable-O0-optnone" to the Clang command line. Cheers. Tim.
Digvijay Gour via llvm-dev
2019-Apr-08 22:07 UTC
[llvm-dev] GVN-Hoist test case not working
It works! Thank You On Mon, Apr 8, 2019 at 6:21 PM Tim Northover <t.p.northover at gmail.com> wrote:> On Mon, 8 Apr 2019 at 12:22, Digvijay Gour via llvm-dev > <llvm-dev at lists.llvm.org> wrote: > > I was trying a basic example on LLVM GVN Hoist and output differs from > what I expect. Am I missing something ? > > At -O0 Clang usually attaches the "optnone" attribute to functions it > generates, which disables all LLVM passes even if they get run. Try > adding "-Xclang -disable-O0-optnone" to the Clang command line. > > Cheers. > > Tim. >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20190409/64e66f32/attachment.html>