[PATCH] D150422: [ConstantFolding] fold integers whose bitwidth is greater than 63, and not multiplies of 8
Kohei Asano via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu May 11 21:37:29 PDT 2023
khei4 created this revision.
Herald added subscribers: pengfei, hiraditya.
Herald added a project: All.
khei4 requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
This patch tries to fold integers whose bit width is greater than 63, and not multiplies of 8.
TODO: confirm the correctness of not multiplies of 8 integer.
https://reviews.llvm.org/D150422
Files:
llvm/lib/Analysis/ConstantFolding.cpp
llvm/test/CodeGen/X86/load-local-v4i5.ll
llvm/test/Transforms/InstCombine/load-store-forward.ll
Index: llvm/test/Transforms/InstCombine/load-store-forward.ll
===================================================================
--- llvm/test/Transforms/InstCombine/load-store-forward.ll
+++ llvm/test/Transforms/InstCombine/load-store-forward.ll
@@ -39,10 +39,13 @@
}
define i17 @vec_store_load_first_odd_size(ptr %p) {
-; CHECK-LABEL: @vec_store_load_first_odd_size(
-; CHECK-NEXT: store <2 x i17> <i17 1, i17 2>, ptr [[P:%.*]], align 8
-; CHECK-NEXT: [[LOAD:%.*]] = load i17, ptr [[P]], align 4
-; CHECK-NEXT: ret i17 [[LOAD]]
+; LITTLE-LABEL: @vec_store_load_first_odd_size(
+; LITTLE-NEXT: store <2 x i17> <i17 1, i17 2>, ptr [[P:%.*]], align 8
+; LITTLE-NEXT: ret i17 1
+;
+; BIG-LABEL: @vec_store_load_first_odd_size(
+; BIG-NEXT: store <2 x i17> <i17 1, i17 2>, ptr [[P:%.*]], align 8
+; BIG-NEXT: ret i17 256
;
store <2 x i17> <i17 1, i17 2>, ptr %p
%load = load i17, ptr %p
Index: llvm/test/CodeGen/X86/load-local-v4i5.ll
===================================================================
--- llvm/test/CodeGen/X86/load-local-v4i5.ll
+++ llvm/test/CodeGen/X86/load-local-v4i5.ll
@@ -6,27 +6,24 @@
define void @_start() {
; CHECK-LABEL: _start:
; CHECK: # %bb.0: # %Entry
-; CHECK-NEXT: movl __unnamed_1(%rip), %eax
-; CHECK-NEXT: movl %eax, -12(%rsp)
-; CHECK-NEXT: movzbl -9(%rsp), %ecx
+; CHECK-NEXT: movl $0, -12(%rsp)
+; CHECK-NEXT: movzbl -9(%rsp), %eax
+; CHECK-NEXT: movzbl -11(%rsp), %ecx
; CHECK-NEXT: movzbl -10(%rsp), %edx
-; CHECK-NEXT: movzbl -11(%rsp), %esi
-; CHECK-NEXT: movzbl %cl, %edi
-; CHECK-NEXT: shrb %cl
-; CHECK-NEXT: movb %cl, -2(%rsp)
-; CHECK-NEXT: andl $31, %eax
-; CHECK-NEXT: andl $31, %esi
-; CHECK-NEXT: shll $5, %esi
-; CHECK-NEXT: orl %eax, %esi
+; CHECK-NEXT: movzbl %al, %esi
+; CHECK-NEXT: shrb %al
+; CHECK-NEXT: movb %al, -2(%rsp)
; CHECK-NEXT: andl $31, %edx
; CHECK-NEXT: shll $10, %edx
-; CHECK-NEXT: orl %esi, %edx
-; CHECK-NEXT: movl %edi, %eax
+; CHECK-NEXT: andl $31, %ecx
+; CHECK-NEXT: shll $5, %ecx
+; CHECK-NEXT: orl %edx, %ecx
+; CHECK-NEXT: movl %esi, %eax
; CHECK-NEXT: shll $15, %eax
-; CHECK-NEXT: orl %edx, %eax
+; CHECK-NEXT: orl %ecx, %eax
; CHECK-NEXT: movw %ax, -4(%rsp)
-; CHECK-NEXT: movb %dil, -5(%rsp)
-; CHECK-NEXT: cmpb $31, %dil
+; CHECK-NEXT: movb %sil, -5(%rsp)
+; CHECK-NEXT: cmpb $31, %sil
; CHECK-NEXT: je .LBB0_2
; CHECK-NEXT: # %bb.1: # %Then
; CHECK-NEXT: int3
Index: llvm/lib/Analysis/ConstantFolding.cpp
===================================================================
--- llvm/lib/Analysis/ConstantFolding.cpp
+++ llvm/lib/Analysis/ConstantFolding.cpp
@@ -429,10 +429,6 @@
return true;
if (auto *CI = dyn_cast<ConstantInt>(C)) {
- if (CI->getBitWidth() > 64 ||
- (CI->getBitWidth() & 7) != 0)
- return false;
-
uint64_t Val = CI->getZExtValue();
unsigned IntBytes = unsigned(CI->getBitWidth()/8);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D150422.521550.patch
Type: text/x-patch
Size: 2986 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230512/03cf7525/attachment.bin>
More information about the llvm-commits
mailing list