[PATCH] D37177: [X86] Don't disable slow INC/DEC if optimizing for size
Sanjay Patel via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Sat Aug 26 08:19:40 PDT 2017
spatel added a comment.
This patch intersects with a topic that @RKSimon was hoping to discuss at this year's dev meeting (it was proposed as a BOF for all targets, but I think we were too late to get an official BOF; also, I think Simon is out of the office for a week, so I don't expect any immediate comments from him):
Do we need fake "features" like FeatureSlowIncDec in isel? Can we just uniformly isel inc/dec and then transform it to add/sub in MI based on the CPU's scheduler model? Or maybe the opposite: we isel add/sub as the default and then convert to inc/dec?
This could be a MachineCombiner transform, or it might be easier to have a single-purpose inc/dec conversion pass that uses properties of the scheduler model to drive the decision.
================
Comment at: test/CodeGen/X86/slow-incdec.ll:1-6
; RUN: llc -mtriple=i386-unknown-linux-gnu -mattr=-slow-incdec < %s | FileCheck -check-prefix=INCDEC %s
; RUN: llc -mtriple=i386-unknown-linux-gnu -mattr=+slow-incdec < %s | FileCheck -check-prefix=ADD %s
; check -mattr=-slow-incdec
+; INCDEC-LABEL: slow_1:
; INCDEC-NOT: addl $-1
----------------
I don't know why these tests are this complicated. We can check for inc/dec output with tests as simple as:
```
$ cat incdec.ll
define i32 @inc(i32 %x) {
%r = add i32 %x, 1
ret i32 %r
}
define i32 @dec(i32 %x) {
%r = add i32 %x, -1
ret i32 %r
}
```
$ ./llc -o - incdec.ll -mtriple=i386-unknown-unkown -mattr=-slow-incdec | grep eax | grep -v mov
incl %eax
decl %eax
$ ./llc -o - incdec.ll -mtriple=i386-unknown-unkown -mattr=+slow-incdec | grep eax | grep -v mov
addl $1, %eax
addl $-1, %eax
https://reviews.llvm.org/D37177
More information about the llvm-commits
mailing list