[llvm] [InstCombine] Thwart complexity-based canonicalization in shl-add test (NFC) (PR #91413)

via llvm-commits llvm-commits at lists.llvm.org
Tue May 7 18:03:43 PDT 2024


https://github.com/AtariDreams updated https://github.com/llvm/llvm-project/pull/91413

>From fcb3c4c46d5b1e28c03d6b815b9e271ea7bccaa5 Mon Sep 17 00:00:00 2001
From: Rose <gfunni234 at gmail.com>
Date: Tue, 7 May 2024 20:48:41 -0400
Subject: [PATCH] [InstCombine] Thwart complexity-based canonicalization in
 shl-add test (NFC)

Fixed test for #88193
---
 llvm/test/Transforms/InstCombine/lshr.ll | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/llvm/test/Transforms/InstCombine/lshr.ll b/llvm/test/Transforms/InstCombine/lshr.ll
index 563e669f9035..fa92c1c4b3be 100644
--- a/llvm/test/Transforms/InstCombine/lshr.ll
+++ b/llvm/test/Transforms/InstCombine/lshr.ll
@@ -397,12 +397,14 @@ define i32 @shl_add_lshr(i32 %x, i32 %c, i32 %y) {
 
 define i32 @shl_add_lshr_comm(i32 %x, i32 %c, i32 %y) {
 ; CHECK-LABEL: @shl_add_lshr_comm(
-; CHECK-NEXT:    [[TMP1:%.*]] = lshr i32 [[Y:%.*]], [[C:%.*]]
+; CHECK-NEXT:    [[Y2:%.*]] = mul i32 [[Y:%.*]], [[Y]]
+; CHECK-NEXT:    [[TMP1:%.*]] = lshr i32 [[Y2]], [[C:%.*]]
 ; CHECK-NEXT:    [[LSHR:%.*]] = add nuw i32 [[TMP1]], [[X:%.*]]
 ; CHECK-NEXT:    ret i32 [[LSHR]]
 ;
   %shl = shl nuw i32 %x, %c
-  %add = add nuw i32 %y, %shl
+  %y2 = mul i32 %y, %y ; thwart complexity-based canonicalization
+  %add = add nuw i32 %y2, %shl
   %lshr = lshr i32 %add, %c
   ret i32 %lshr
 }



More information about the llvm-commits mailing list