[llvm] [SLP] Allow UDiv X, C <--> LShr X, log2(C) tranformations in BinOpSameOpcodeHelper (PR #181731)

Ryan Buchner via llvm-commits llvm-commits at lists.llvm.org
Tue Feb 17 12:52:24 PST 2026


================
@@ -7,25 +7,18 @@ define void @partial_vec_invalid_cost() #0 {
 ; CHECK-LABEL: define void @partial_vec_invalid_cost(
 ; CHECK-SAME: ) #[[ATTR0:[0-9]+]] {
 ; CHECK-NEXT:  entry:
-; CHECK-NEXT:    [[LSHR_1:%.*]] = lshr i96 0, 0
-; CHECK-NEXT:    [[LSHR_2:%.*]] = lshr i96 0, 0
-; CHECK-NEXT:    [[TMP0:%.*]] = insertelement <4 x i96> poison, i96 [[LSHR_1]], i32 0
-; CHECK-NEXT:    [[TMP1:%.*]] = insertelement <4 x i96> [[TMP0]], i96 [[LSHR_2]], i32 1
-; CHECK-NEXT:    [[TMP2:%.*]] = insertelement <4 x i96> [[TMP1]], i96 0, i32 2
-; CHECK-NEXT:    [[TMP3:%.*]] = insertelement <4 x i96> [[TMP2]], i96 0, i32 3
-; CHECK-NEXT:    [[TMP4:%.*]] = trunc <4 x i96> [[TMP3]] to <4 x i32>
-; CHECK-NEXT:    [[RDX_OP:%.*]] = or <4 x i32> zeroinitializer, [[TMP4]]
-; CHECK-NEXT:    [[OP_RDX3:%.*]] = call i32 @llvm.vector.reduce.or.v4i32(<4 x i32> [[RDX_OP]])
+; CHECK-NEXT:    [[OP_RDX3:%.*]] = call i32 @llvm.vector.reduce.or.v4i32(<4 x i32> zeroinitializer)
 ; CHECK-NEXT:    [[STORE_THIS:%.*]] = zext i32 [[OP_RDX3]] to i96
 ; CHECK-NEXT:    store i96 [[STORE_THIS]], ptr null, align 16
 ; CHECK-NEXT:    ret void
 ;
 entry:
-
-  %lshr.1 = lshr i96 0, 0 ; These ops
-  %lshr.2 = lshr i96 0, 0 ; return an
-  %add.0 = add i96 0, 0   ; invalid
-  %add.1 = add i96 0, 0   ; vector cost.
+  ; Test is broken, I don't think there are any pairs of binary ops that
+  ; can give an invalid cost
+  %lshr.1 = lshr i96 0, 0
+  %lshr.2 = lshr i96 0, 0
+  %add.0 = add i96 0, 0
+  %add.1 = add i96 0, 0
----------------
bababuck wrote:

Updated the test. My understanding is that the intention was to create a TreeEntry with an Invalid vector cost. Was able to change the constants to avoid the binary op transformation so that the Invalid cost remains. This test was originally added in 4652ec0e291c by @patrick-rivos 

https://github.com/llvm/llvm-project/pull/181731


More information about the llvm-commits mailing list