forked from llvm-mirror/llvm
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add intermediate subtract instructions to reassociation worklist.
We sometimes create intermediate subtract instructions during reassociation. Adding these to the worklist to revisit exposes many additional reassociation opportunities. Patch by Aditya Nandakumar. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@253240 91177308-0d34-0410-b5e6-96231b3b80d8
- Loading branch information
Showing
9 changed files
with
87 additions
and
26 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
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
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,31 @@ | ||
; RUN: opt < %s -reassociate -S | FileCheck %s | ||
; CHECK-LABEL: faddsubAssoc1 | ||
; CHECK: [[TMP1:%tmp.*]] = fmul fast half %a, 0xH4500 | ||
; CHECK: [[TMP2:%tmp.*]] = fmul fast half %b, 0xH4500 | ||
; CHECK: fsub fast half [[TMP2]], [[TMP1]] | ||
; CHECK: ret | ||
; Input is A op (B op C) | ||
define half @faddsubAssoc1(half %a, half %b) { | ||
%tmp1 = fmul fast half %b, 0xH4200 ; 3*b | ||
%tmp2 = fmul fast half %a, 0xH4500 ; 5*a | ||
%tmp3 = fmul fast half %b, 0xH4000 ; 2*b | ||
%tmp4 = fsub fast half %tmp2, %tmp1 ; 5 * a - 3 * b | ||
%tmp5 = fsub fast half %tmp3, %tmp4 ; 2 * b - ( 5 * a - 3 * b) | ||
ret half %tmp5 ; = 5 * (b - a) | ||
} | ||
|
||
; CHECK-LABEL: faddsubAssoc2 | ||
; CHECK: [[TMP1:%tmp.*]] = fmul fast half %a, 0xH4500 | ||
; CHECK: [[TMP2:%tmp.*]] = fmul fast half %b, 0xH3C00 | ||
; CHECK: fadd fast half [[TMP2]], [[TMP1]] | ||
; CHECK: ret | ||
; Input is (A op B) op C | ||
define half @faddsubAssoc2(half %a, half %b) { | ||
%tmp1 = fmul fast half %b, 0xH4200 ; 3*b | ||
%tmp2 = fmul fast half %a, 0xH4500 ; 5*a | ||
%tmp3 = fmul fast half %b, 0xH4000 ; 2*b | ||
%tmp4 = fadd fast half %tmp2, %tmp1 ; 5 * a + 3 * b | ||
%tmp5 = fsub fast half %tmp4, %tmp3 ; (5 * a + 3 * b) - (2 * b) | ||
ret half %tmp5 ; = 5 * a + b | ||
} | ||
|
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