Files
TheRock/compiler/amd-llvm/llvm/test/Transforms/Reassociate/defeat-licm.ll
T
derek.holloway 7502bf64a4
CodeQL / Analyze (actions) (push) Canceled after 0s
CodeQL / Analyze (python) (push) Canceled after 0s
pre-commit / pre-commit (push) Canceled after 0s
Multi-Arch CI / setup (push) Canceled after 0s
Publish build_manylinux_x86_64 images / publish_build_manylinux_x86_64 (push) Canceled after 0s
Setup (Multi-Arch) / setup (push) Canceled after 0s
Multi-Arch CI / Linux::${{ fromJSON(needs.setup.outputs.linux_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubi10 image / publish_no_rocm_image_ubi10 (push) Canceled after 0s
Multi-Arch CI / Windows::${{ fromJSON(needs.setup.outputs.windows_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Multi-Arch CI / Manifest Diff (push) Canceled after 0s
TheRock Manifest Diff Report / Generate Manifest Diff Report (push) Canceled after 0s
Multi-Arch CI / CI Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_ocl_rt images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_rocgdb images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Unit Tests / Unit Tests :: ubuntu-24.04 (push) Canceled after 0s
Unit Tests / Unit Tests :: windows-2022 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_media (push) Canceled after 0s
Unit Tests / Unit Tests Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_openmpi (push) Canceled after 0s
Flatten subprojects into a single base monorepo
2026-09-02 16:34:47 -07:00

70 lines
3.5 KiB
LLVM

; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 2
; Check that the default heuristic use the local cse constraints.
; RUN: opt -S -passes=reassociate %s -o - | FileCheck %s -check-prefix=LOCAL_CSE
; RUN: opt -S -passes=reassociate %s -reassociate-use-cse-local=true -o - | FileCheck %s -check-prefix=LOCAL_CSE
; RUN: opt -S -passes=reassociate %s -reassociate-use-cse-local=false -o - | FileCheck %s -check-prefix=CSE
; In the local CSE mode, we check that we don't create loop dependent
; expressions in order to expose more CSE opportunities.
; This can be seen with %inv4 and %inv5 that should stay in the entry block.
;
; For the non-local CSE mode, we form CSE-able expression regardless of where
; they would be materialized. In this case, %inv4 and %inv5 are pushed
; down the loop body in order to make loop_dependent, %inv2 appear as a
; sub-expression.
;
; Related to issue PR61458.
define void @reassoc_defeats_licm(i64 %inv1, i64 %inv2, i64 %inv3) {
; LOCAL_CSE-LABEL: define void @reassoc_defeats_licm
; LOCAL_CSE-SAME: (i64 [[INV1:%.*]], i64 [[INV2:%.*]], i64 [[INV3:%.*]]) {
; LOCAL_CSE-NEXT: bb:
; LOCAL_CSE-NEXT: [[INV4:%.*]] = add nuw nsw i64 [[INV2]], [[INV1]]
; LOCAL_CSE-NEXT: [[INV5:%.*]] = add nuw nsw i64 [[INV3]], [[INV2]]
; LOCAL_CSE-NEXT: br label [[BB214:%.*]]
; LOCAL_CSE: bb214:
; LOCAL_CSE-NEXT: [[IV1:%.*]] = phi i64 [ [[IV2:%.*]], [[BB214]] ], [ 0, [[BB:%.*]] ]
; LOCAL_CSE-NEXT: [[IV2]] = phi i64 [ [[IV2_PLUS_1:%.*]], [[BB214]] ], [ 1, [[BB]] ]
; LOCAL_CSE-NEXT: [[LOOP_DEPENDENT:%.*]] = shl nuw nsw i64 [[IV1]], 13
; LOCAL_CSE-NEXT: [[LOOP_DEPENDENT2:%.*]] = add nsw i64 [[INV4]], [[LOOP_DEPENDENT]]
; LOCAL_CSE-NEXT: call void @keep_alive(i64 [[LOOP_DEPENDENT2]])
; LOCAL_CSE-NEXT: [[LOOP_DEPENDENT3:%.*]] = add i64 [[INV5]], [[LOOP_DEPENDENT]]
; LOCAL_CSE-NEXT: call void @keep_alive(i64 [[LOOP_DEPENDENT3]])
; LOCAL_CSE-NEXT: [[IV2_PLUS_1]] = add i64 [[IV2]], 1
; LOCAL_CSE-NEXT: br label [[BB214]]
;
; CSE-LABEL: define void @reassoc_defeats_licm
; CSE-SAME: (i64 [[INV1:%.*]], i64 [[INV2:%.*]], i64 [[INV3:%.*]]) {
; CSE-NEXT: bb:
; CSE-NEXT: br label [[BB214:%.*]]
; CSE: bb214:
; CSE-NEXT: [[IV1:%.*]] = phi i64 [ [[IV2:%.*]], [[BB214]] ], [ 0, [[BB:%.*]] ]
; CSE-NEXT: [[IV2]] = phi i64 [ [[IV2_PLUS_1:%.*]], [[BB214]] ], [ 1, [[BB]] ]
; CSE-NEXT: [[LOOP_DEPENDENT:%.*]] = shl nuw nsw i64 [[IV1]], 13
; CSE-NEXT: [[INV4:%.*]] = add i64 [[LOOP_DEPENDENT]], [[INV2]]
; CSE-NEXT: [[LOOP_DEPENDENT2:%.*]] = add i64 [[INV4]], [[INV1]]
; CSE-NEXT: call void @keep_alive(i64 [[LOOP_DEPENDENT2]])
; CSE-NEXT: [[INV5:%.*]] = add i64 [[LOOP_DEPENDENT]], [[INV2]]
; CSE-NEXT: [[LOOP_DEPENDENT3:%.*]] = add i64 [[INV5]], [[INV3]]
; CSE-NEXT: call void @keep_alive(i64 [[LOOP_DEPENDENT3]])
; CSE-NEXT: [[IV2_PLUS_1]] = add i64 [[IV2]], 1
; CSE-NEXT: br label [[BB214]]
;
bb:
%inv4 = add nuw nsw i64 %inv1, %inv2
%inv5 = add nuw nsw i64 %inv2, %inv3
br label %bb214
bb214: ; preds = %bb214, %bb
%iv1 = phi i64 [ %iv2, %bb214 ], [ 0, %bb ]
%iv2 = phi i64 [ %iv2_plus_1, %bb214 ], [ 1, %bb ]
%loop_dependent = shl nuw nsw i64 %iv1, 13
%loop_dependent2 = add nsw i64 %inv4, %loop_dependent
call void @keep_alive(i64 %loop_dependent2)
%loop_dependent3 = add i64 %inv5, %loop_dependent
call void @keep_alive(i64 %loop_dependent3)
%iv2_plus_1 = add i64 %iv2, 1
br label %bb214
}
declare void @keep_alive(i64)