The REM DAG combine uses the visitDivLike functions to try and get an optimized DIV node to provide better codegen, however in some cases this visitDivLike call ends up in the BuildSDIVPow2 target hook, which in turn sometimes will return the same node passed in to indicate not to change it. The REM DAG combine does not anticipate this and creates a cycle in the DAG because of it. Fix this by ensuring any such optimized div node returned is distinct from the node being combined. Differential Revision: https://reviews.llvm.org/D114716
20 lines
762 B
LLVM
20 lines
762 B
LLVM
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
|
|
; RUN: llc < %s | FileCheck %s
|
|
|
|
target triple = "aarch64-unknown-linux-gnu"
|
|
|
|
define <vscale x 4 x i32> @srem_combine_loop(<vscale x 4 x i32> %a) #0 {
|
|
; CHECK-LABEL: srem_combine_loop:
|
|
; CHECK: // %bb.0:
|
|
; CHECK-NEXT: mov z1.d, z0.d
|
|
; CHECK-NEXT: ptrue p0.s
|
|
; CHECK-NEXT: asrd z1.s, p0/m, z1.s, #1
|
|
; CHECK-NEXT: mov z2.s, #2 // =0x2
|
|
; CHECK-NEXT: mls z0.s, p0/m, z1.s, z2.s
|
|
; CHECK-NEXT: ret
|
|
%rem = srem <vscale x 4 x i32> %a, shufflevector (<vscale x 4 x i32> insertelement (<vscale x 4 x i32> poison, i32 2, i32 0), <vscale x 4 x i32> poison, <vscale x 4 x i32> zeroinitializer)
|
|
ret <vscale x 4 x i32> %rem
|
|
}
|
|
|
|
attributes #0 = { "target-features"="+sve" }
|