-
Notifications
You must be signed in to change notification settings - Fork 15.2k
[InstCombine] Fold select(X >s 0, 0, -X) | smax(X, 0) to abs(X) #165200
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
4629547
af62083
21ca09a
1e9a8ce
e5d284b
e19950b
28f1987
bd8b791
154c2c1
3aaa55a
c01eb5a
4c92c7c
d6eecb3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2113,3 +2113,31 @@ define <4 x i32> @or_zext_nneg_minus_constant_splat(<4 x i8> %a) { | |
| %or = or <4 x i32> %zext, splat (i32 -9) | ||
| ret <4 x i32> %or | ||
| } | ||
|
|
||
| define i8 @or_positive_minus_non_positive_to_abs(i8 noundef %0){ | ||
| ; CHECK-LABEL: @or_positive_minus_non_positive_to_abs( | ||
| ; CHECK-NEXT: [[TMP2:%.*]] = call i8 @llvm.abs.i8(i8 [[TMP0:%.*]], i1 false) | ||
| ; CHECK-NEXT: ret i8 [[TMP2]] | ||
| ; | ||
| %2 = icmp sgt i8 %0, zeroinitializer | ||
|
||
| %3 = sext i1 %2 to i8 | ||
| %4 = sub i8 zeroinitializer, %0 | ||
| %5 = xor i8 %3, -1 | ||
| %6 = and i8 %4, %5 | ||
| %7 = and i8 %0, %3 | ||
| %8 = or i8 %6, %7 | ||
| ret i8 %8 | ||
| } | ||
|
|
||
| define <2 x i8> @or_select_smax_to_abs(<2 x i8> %0){ | ||
| ; CHECK-LABEL: @or_select_smax_to_abs( | ||
| ; CHECK-NEXT: [[TMP2:%.*]] = call <2 x i8> @llvm.abs.v2i8(<2 x i8> [[TMP0:%.*]], i1 false) | ||
| ; CHECK-NEXT: ret <2 x i8> [[TMP2]] | ||
| ; | ||
| %2 = icmp sgt <2 x i8> %0, zeroinitializer | ||
| %3 = sub <2 x i8> zeroinitializer, %0 | ||
| %4 = select <2 x i1> %2, <2 x i8> zeroinitializer, <2 x i8> %3 | ||
| %5 = tail call <2 x i8> @llvm.smax.v2i8(<2 x i8> %0, <2 x i8> zeroinitializer) | ||
| %6 = or <2 x i8> %4, %5 | ||
| ret <2 x i8> %6 | ||
| } | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Missing negative test for the multiple use case
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
done |
||
Uh oh!
There was an error while loading. Please reload this page.