llvm.org GIT mirror llvm / 1368f40
Merging r312509: ------------------------------------------------------------------------ r312509 | dannyb | 2017-09-04 19:17:42 -0700 (Mon, 04 Sep 2017) | 1 line NewGVN: Fix PR 34452 by passing instruction all the way down when we do aggregate value simplification ------------------------------------------------------------------------ git-svn-id: https://llvm.org/svn/llvm-project/llvm/branches/release_50@319952 91177308-0d34-0410-b5e6-96231b3b80d8 Tom Stellard 1 year, 8 months ago
2 changed file(s) with 58 addition(s) and 7 deletion(s). Raw diff Collapse all Expand all
585585 private:
586586 // Expression handling.
587587 const Expression *createExpression(Instruction *) const;
588 const Expression *createBinaryExpression(unsigned, Type *, Value *,
589 Value *) const;
588 const Expression *createBinaryExpression(unsigned, Type *, Value *, Value *,
589 Instruction *) const;
590590 PHIExpression *createPHIExpression(Instruction *, bool &HasBackEdge,
591591 bool &OriginalOpsConstant) const;
592592 const DeadExpression *createDeadExpression() const;
901901 }
902902
903903 const Expression *NewGVN::createBinaryExpression(unsigned Opcode, Type *T,
904 Value *Arg1,
905 Value *Arg2) const {
904 Value *Arg1, Value *Arg2,
905 Instruction *I) const {
906906 auto *E = new (ExpressionAllocator) BasicExpression(2);
907907
908908 E->setType(T);
920920 E->op_push_back(lookupOperandLeader(Arg2));
921921
922922 Value *V = SimplifyBinOp(Opcode, E->getOperand(0), E->getOperand(1), SQ);
923 if (const Expression *SimplifiedE = checkSimplificationResults(E, nullptr, V))
923 if (const Expression *SimplifiedE = checkSimplificationResults(E, I, V))
924924 return SimplifiedE;
925925 return E;
926926 }
16981698 // expression.
16991699 assert(II->getNumArgOperands() == 2 &&
17001700 "Expect two args for recognised intrinsics.");
1701 return createBinaryExpression(
1702 Opcode, EI->getType(), II->getArgOperand(0), II->getArgOperand(1));
1701 return createBinaryExpression(Opcode, EI->getType(),
1702 II->getArgOperand(0),
1703 II->getArgOperand(1), I);
17031704 }
17041705 }
17051706 }
19321933 }
19331934
19341935 void NewGVN::addAdditionalUsers(Value *To, Value *User) const {
1936 assert(User && To != User);
19351937 if (isa(To))
19361938 AdditionalUsers[To].insert(User);
19371939 }
0 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
1 ; RUN: opt -newgvn -S < %s | FileCheck %s
2 ;; Ensure we don't crash when simplifying aggregate value expressions
3 source_filename = "bugpoint-output-09f7a24.bc"
4
5 @WHOLELINE = external local_unnamed_addr global i32, align 4
6
7 ; Function Attrs: nounwind uwtable
8 define void @sgrep() local_unnamed_addr #0 {
9 ; CHECK-LABEL: @sgrep(
10 ; CHECK-NEXT: entry:
11 ; CHECK-NEXT: [[TMP0:%.*]] = load i32, i32* @WHOLELINE, align 4, !tbaa !1
12 ; CHECK-NEXT: [[TOBOOL:%.*]] = icmp eq i32 [[TMP0]], 0
13 ; CHECK-NEXT: [[DOT:%.*]] = select i1 [[TOBOOL]], i32 2048, i32 2047
14 ; CHECK-NEXT: br label [[WHILE_BODY_US:%.*]]
15 ; CHECK: while.body.us:
16 ; CHECK-NEXT: [[START_1230_US:%.*]] = phi i32 [ [[DOT]], [[ENTRY:%.*]] ], [ 0, [[WHILE_BODY_US]] ]
17 ; CHECK-NEXT: [[TMP1:%.*]] = sext i32 [[START_1230_US]] to i64
18 ; CHECK-NEXT: [[TMP2:%.*]] = call { i64, i1 } @llvm.sadd.with.overflow.i64(i64 0, i64 [[TMP1]])
19 ; CHECK-NEXT: br label [[WHILE_BODY_US]]
20 ;
21 entry:
22 %0 = load i32, i32* @WHOLELINE, align 4, !tbaa !1
23 %tobool = icmp eq i32 %0, 0
24 %. = select i1 %tobool, i32 2048, i32 2047
25 br label %while.body.us
26
27 while.body.us: ; preds = %while.body.us, %entry
28 %start.1230.us = phi i32 [ %., %entry ], [ 0, %while.body.us ]
29 %1 = sext i32 %start.1230.us to i64
30 %2 = call { i64, i1 } @llvm.sadd.with.overflow.i64(i64 0, i64 %1)
31 %.res302 = extractvalue { i64, i1 } %2, 0
32 %3 = icmp sge i64 undef, %.res302
33 br label %while.body.us
34 }
35
36 ; Function Attrs: nounwind readnone speculatable
37 declare { i64, i1 } @llvm.sadd.with.overflow.i64(i64, i64) #1
38
39 attributes #0 = { nounwind uwtable "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "less-precise-fpmad"="false" "no-frame-pointer-elim"="false" "no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="false" "polly-optimized" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+fxsr,+mmx,+sse,+sse2,+x87" "unsafe-fp-math"="false" "use-soft-float"="false" }
40 attributes #1 = { nounwind readnone speculatable }
41
42 !llvm.ident = !{!0}
43
44 !0 = !{!"clang version 6.0.0 (trunk 311664) (llvm/trunk 311666)"}
45 !1 = !{!2, !2, i64 0}
46 !2 = !{!"int", !3, i64 0}
47 !3 = !{!"omnipotent char", !4, i64 0}
48 !4 = !{!"Simple C/C++ TBAA"}