forked from llvm/llvm-project
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[X86] Add a pattern in PreprocessISelDAG.
`%c = shl <X x i1> %a, %b -> %c = %a` As discussed in llvm#85681, this pattern is added to avoid cannot selection error. Since shift one is either identical or UB, we consider it as identical and replace all uses of %c with %a. Tests for shl, ashr, lshr are added. This fixes llvm#85681. Signed-off-by: Peter Rong <PeterRong96@gmail.com>
- Loading branch information
1 parent
4bade55
commit e8dda97
Showing
2 changed files
with
49 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py | ||
; RUN: llc < %s -mtriple=x86_64-- -mcpu=emeraldrapids | FileCheck %s | ||
; RUN: llc < %s -mtriple=x86_64-- -mcpu=sapphirerapids | FileCheck %s | ||
; RUN: llc < %s -mtriple=x86_64-- -mcpu=znver4 | FileCheck %s | ||
|
||
define i32 @shl(i32 %a0) { | ||
; CHECK-LABEL: shl: | ||
; CHECK: # %bb.0: | ||
; CHECK-NEXT: kxnord %k0, %k0, %k0 | ||
; CHECK-NEXT: kmovd %k0, %eax | ||
; CHECK-NEXT: retq | ||
%v0 = bitcast i32 %a0 to <32 x i1> | ||
%s = shl <32 x i1> <i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true>, %v0 | ||
%r = bitcast <32 x i1> %s to i32 | ||
ret i32 %r | ||
} | ||
|
||
define i32 @lshr(i32 %a0) { | ||
; CHECK-LABEL: lshr: | ||
; CHECK: # %bb.0: | ||
; CHECK-NEXT: movl $-1, %eax | ||
; CHECK-NEXT: retq | ||
%v0 = bitcast i32 %a0 to <32 x i1> | ||
%s = lshr <32 x i1> <i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true>, %v0 | ||
%r = bitcast <32 x i1> %s to i32 | ||
ret i32 %r | ||
} | ||
|
||
|
||
define i32 @ashr(i32 %a0) { | ||
; CHECK-LABEL: ashr: | ||
; CHECK: # %bb.0: | ||
; CHECK-NEXT: movl $-1, %eax | ||
; CHECK-NEXT: retq | ||
%v0 = bitcast i32 %a0 to <32 x i1> | ||
%s = ashr <32 x i1> <i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true>, %v0 | ||
%r = bitcast <32 x i1> %s to i32 | ||
ret i32 %r | ||
} |