-
Notifications
You must be signed in to change notification settings - Fork 11.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[AArch64] Fix comparison peephole opt with non-0/1 immediate (PR51476)
This is a non-intrusive fix for https://bugs.llvm.org/show_bug.cgi?id=51476 intended for backport to the 13.x release branch. It expands on the current hack by distinguishing between CmpValue of 0, 1 and 2, where 0 and 1 have the obvious meaning and 2 means "anything else". The new optimization from D98564 should only be performed for CmpValue of 0 or 1. For main, I think we should switch the analyzeCompare() and optimizeCompare() APIs to use int64_t instead of int, which is in line with MachineOperand's notion of an immediate, and avoids this problem altogether. Differential Revision: https://reviews.llvm.org/D108076
- Loading branch information
Showing
3 changed files
with
93 additions
and
15 deletions.
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
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,35 @@ | ||
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py | ||
; RUN: llc -mtriple=aarch64-unknown-linux-gnu < %s | FileCheck %s | ||
|
||
define void @test(i8 %arg) nounwind { | ||
; CHECK-LABEL: test: | ||
; CHECK: // %bb.0: | ||
; CHECK-NEXT: str x30, [sp, #-16]! // 8-byte Folded Spill | ||
; CHECK-NEXT: and w8, w0, #0xff | ||
; CHECK-NEXT: cmp w8, #1 | ||
; CHECK-NEXT: cset w0, ne | ||
; CHECK-NEXT: cmp w0, #3 | ||
; CHECK-NEXT: strb w0, [sp, #12] | ||
; CHECK-NEXT: b.eq .LBB0_2 | ||
; CHECK-NEXT: // %bb.1: // %do_call | ||
; CHECK-NEXT: bl unknown | ||
; CHECK-NEXT: .LBB0_2: // %common.ret | ||
; CHECK-NEXT: ldr x30, [sp], #16 // 8-byte Folded Reload | ||
; CHECK-NEXT: ret | ||
%tmp = alloca i8 | ||
%cmp1 = icmp ne i8 %arg, 1 | ||
%zext = zext i1 %cmp1 to i8 | ||
store i8 %zext, i8* %tmp | ||
%zext2 = load i8, i8* %tmp | ||
%cmp2 = icmp eq i8 %zext2, 3 | ||
br i1 %cmp2, label %exit, label %do_call | ||
|
||
do_call: | ||
call void @unknown(i8 %zext2) | ||
ret void | ||
|
||
exit: | ||
ret void | ||
} | ||
|
||
declare void @unknown(i8) |