1 ; RUN: opt -passes=gvn %s -S | FileCheck %s
2 ; PR42605. Check phi-translate won't translate the value number of a call
3 ; to the value of another call with clobber in between.
4 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
5 target triple = "x86_64-unknown-linux-gnu"
7 @global = dso_local local_unnamed_addr global i32 0, align 4
8 @.str = private unnamed_addr constant [8 x i8] c"%d, %d\0A\00", align 1
10 ; Function Attrs: nofree nounwind
11 declare dso_local i32 @printf(ptr nocapture readonly, ...) local_unnamed_addr
13 ; Function Attrs: noinline norecurse nounwind readonly uwtable
14 define dso_local i32 @_Z3gooi(i32 %i) local_unnamed_addr #0 {
16 %t0 = load i32, ptr @global, align 4, !tbaa !2
17 %add = add nsw i32 %t0, %i
21 ; Function Attrs: nofree nounwind uwtable
22 define dso_local void @noclobber() local_unnamed_addr {
24 %call = tail call i32 @_Z3gooi(i32 2)
25 %add = add nsw i32 %call, 5
26 %cmp = icmp sgt i32 %add, 2
27 br i1 %cmp, label %if.then, label %if.end
29 if.then: ; preds = %entry
30 %call1 = tail call i32 @_Z3gooi(i32 3)
31 %add2 = add nsw i32 %call1, 5
34 ; Check pre happens after phitranslate.
35 ; CHECK-LABEL: @noclobber
36 ; CHECK: %add4.pre-phi = phi i32 [ %add2, %if.then ], [ %add, %entry ]
37 ; CHECK: printf(ptr @.str, i32 %global2.0, i32 %add4.pre-phi)
39 if.end: ; preds = %if.then, %entry
40 %i.0 = phi i32 [ 3, %if.then ], [ 2, %entry ]
41 %global2.0 = phi i32 [ %add2, %if.then ], [ %add, %entry ]
42 %call3 = tail call i32 @_Z3gooi(i32 %i.0)
43 %add4 = add nsw i32 %call3, 5
44 %call5 = tail call i32 (ptr, ...) @printf(ptr @.str, i32 %global2.0, i32 %add4)
48 ; Function Attrs: nofree nounwind uwtable
49 define dso_local void @hasclobber() local_unnamed_addr {
51 %call = tail call i32 @_Z3gooi(i32 2)
52 %add = add nsw i32 %call, 5
53 %cmp = icmp sgt i32 %add, 2
54 br i1 %cmp, label %if.then, label %if.end
56 if.then: ; preds = %entry
57 %call1 = tail call i32 @_Z3gooi(i32 3)
58 %add2 = add nsw i32 %call1, 5
61 ; Check no pre happens.
62 ; CHECK-LABEL: @hasclobber
63 ; CHECK: %call3 = tail call i32 @_Z3gooi(i32 %i.0)
64 ; CHECK-NEXT: %add4 = add nsw i32 %call3, 5
65 ; CHECK-NEXT: printf(ptr @.str, i32 %global2.0, i32 %add4)
67 if.end: ; preds = %if.then, %entry
68 %i.0 = phi i32 [ 3, %if.then ], [ 2, %entry ]
69 %global2.0 = phi i32 [ %add2, %if.then ], [ %add, %entry ]
70 store i32 5, ptr @global, align 4, !tbaa !2
71 %call3 = tail call i32 @_Z3gooi(i32 %i.0)
72 %add4 = add nsw i32 %call3, 5
73 %call5 = tail call i32 (ptr, ...) @printf(ptr @.str, i32 %global2.0, i32 %add4)
77 attributes #0 = { noinline norecurse nounwind readonly uwtable "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "frame-pointer"="none" "less-precise-fpmad"="false" "min-legal-vector-width"="0" "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"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "unsafe-fp-math"="false" "use-soft-float"="false" }
79 !llvm.module.flags = !{!0}
82 !0 = !{i32 1, !"wchar_size", i32 4}
83 !1 = !{!"clang version 10.0.0 (trunk 369798)"}
85 !3 = !{!"int", !4, i64 0}
86 !4 = !{!"omnipotent char", !5, i64 0}
87 !5 = !{!"Simple C++ TBAA"}