Alexis Engelke 5b40a05d8f
[InstCombine] Don't look at ConstantData users
When looking at PHI operand for combining, only look at instructions and
arguments. The loop later iteraters over Arg's users, which is not
useful if Arg is a constant -- it's users are not meaningful and might
be in different functions, which causes problems for the dominates()
query.

Pull Request: https://github.com/llvm/llvm-project/pull/103302
2024-08-13 20:44:45 +02:00

45 lines
1.1 KiB
LLVM

; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 5
; RUN: opt -S < %s -passes=instcombine | FileCheck %s
; Verify that instcombine doesn't look at users of Constant in different
; functions for dominates() queries.
define void @f1(i1 %a) {
; CHECK-LABEL: define void @f1(
; CHECK-SAME: i1 [[A:%.*]]) {
; CHECK-NEXT: br label %[[BB1:.*]]
; CHECK: [[BB1]]:
; CHECK-NEXT: br i1 [[A]], label %[[BB3:.*]], label %[[BB2:.*]]
; CHECK: [[BB2]]:
; CHECK-NEXT: br label %[[BB3]]
; CHECK: [[BB3]]:
; CHECK-NEXT: [[PHI:%.*]] = phi i64 [ 0, %[[BB2]] ], [ 1, %[[BB1]] ]
; CHECK-NEXT: [[INTTOPTR:%.*]] = inttoptr i64 [[PHI]] to ptr
; CHECK-NEXT: store i32 0, ptr [[INTTOPTR]], align 4
; CHECK-NEXT: br label %[[BB1]]
;
br label %bb1
bb1:
br i1 %a, label %bb3, label %bb2
bb2:
br label %bb3
bb3:
%phi = phi i64 [ 0, %bb2 ], [ 1, %bb1 ]
%inttoptr = inttoptr i64 %phi to ptr
store i32 0, ptr %inttoptr, align 4
br label %bb1
}
define void @f2() {
; CHECK-LABEL: define void @f2() {
; CHECK-NEXT: [[BB:.*:]]
; CHECK-NEXT: ret void
;
bb:
%inttoptr = inttoptr i64 0 to ptr
ret void
}