[ValueTracking] Fix assert message and add test case for r340546 and PR38677.

The bug was already fixed. This just adds a test case for it.

llvm-svn: 340556
This commit is contained in:
Craig Topper 2018-08-23 17:45:53 +00:00
parent bbf70ad02e
commit da9171ac7d
2 changed files with 34 additions and 1 deletions

View File

@ -2215,7 +2215,7 @@ static bool isSignedMinMaxClamp(const Value *Select, const Value *&In,
const APInt *&CLow, const APInt *&CHigh) {
assert(isa<Operator>(Select) &&
cast<Operator>(Select)->getOpcode() == Instruction::Select &&
"Input should be a SelectInst!");
"Input should be a Select!");
const Value *LHS, *RHS, *LHS2, *RHS2;
SelectPatternFlavor SPF = matchSelectPattern(Select, LHS, RHS).Flavor;

View File

@ -0,0 +1,33 @@
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
;RUN: opt -instcombine -S %s | FileCheck %s
@A = extern_weak global i32, align 4
@B = extern_weak global i32, align 4
define i32 @foo(i1 %which) {
; CHECK-LABEL: @foo(
; CHECK-NEXT: entry:
; CHECK-NEXT: br i1 true, label [[FINAL:%.*]], label [[DELAY:%.*]]
; CHECK: delay:
; CHECK-NEXT: br label [[FINAL]]
; CHECK: final:
; CHECK-NEXT: [[USE2:%.*]] = phi i32 [ 1, [[ENTRY:%.*]] ], [ select (i1 icmp eq (i32* @A, i32* @B), i32 2, i32 1), [[DELAY]] ]
; CHECK-NEXT: [[B7:%.*]] = mul i32 [[USE2]], 2147483647
; CHECK-NEXT: [[C3:%.*]] = icmp eq i32 [[B7]], 0
; CHECK-NEXT: store i1 [[C3]], i1* undef, align 1
; CHECK-NEXT: ret i32 [[USE2]]
;
entry:
br i1 true, label %final, label %delay
delay: ; preds = %entry
br label %final
final: ; preds = %delay, %entry
%use2 = phi i1 [ false, %entry ], [ icmp eq (i32* @A, i32* @B), %delay ]
%value = select i1 %use2, i32 2, i32 1
%B7 = mul i32 %value, 2147483647
%C3 = icmp ule i32 %B7, 0
store i1 %C3, i1* undef
ret i32 %value
}