xref: /llvm-project/llvm/test/Transforms/InstCombine/pr56424.ll (revision ef7aed3e112b47641ca2704187d3701765a831ce)
1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2; RUN: opt < %s --passes=instcombine -S | FileCheck %s
3
4; This would crash if we didn't check for a negative shift.
5; https://github.com/llvm/llvm-project/issues/56424
6define i64 @PR56424(i1 %cond, i32 %arg) {
7; CHECK-LABEL: @PR56424(
8; CHECK-NEXT:  entry:
9; CHECK-NEXT:    br i1 [[COND:%.*]], label [[IF_THEN:%.*]], label [[IF_END:%.*]]
10; CHECK:       if.then:
11; CHECK-NEXT:    br label [[IF_END]]
12; CHECK:       if.end:
13; CHECK-NEXT:    ret i64 0
14;
15entry:
16  br i1 %cond, label %if.then, label %if.end
17
18if.then:
19  %shr  = ashr i32 %arg, -2
20  %sext = sext i32 %shr to i64
21  br label %if.end
22
23if.end:
24  %val = phi i64 [ %sext, %if.then ], [ 0, %entry ]
25  %and = and i64 -81, %val
26  ret i64 %and
27}
28