Issue |
141137
|
Summary |
[AArch64] Need to adjust comparison with -1 to comparison with 0 when it is beneficial
|
Labels |
new issue
|
Assignees |
|
Reporter |
AZero13
|
When I corrected an issue with getAArch64Cmp: the following changed:
; CHECK-SD-NEXT: ands w8, w8, w8, asr #31
; CHECK-SD-NEXT: csinv w8, w8, wzr, ge
to
; CHECK-SD-NEXT: and w8, w8, w8, asr #31
; CHECK-SD-NEXT: cmn w8, #1
; CHECK-SD-NEXT: csinv w8, w8, wzr, gt
Now, this is only one regression; the rest of the changes are improvements. However, it made me realize an issue: the compiler is peephole optimizing a compare with -1 but not because it is better, but because it thought -1 was not a legal immediate for a compare, which my patch corrects the compiler into realizing -1 is a valid cmp, so it changes it to a comparison with 0, which is beneficial in a tiny number of cases, like this one, but does more harm than good.
So the issue is not with this patch, but rather, we ought to peephole optimize a comparison with -1 to be a comparison with 0, if we know cse will do the job.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs