diff options
| author | Sanjay Patel <spatel@rotateright.com> | 2016-12-19 18:35:37 +0000 |
|---|---|---|
| committer | Sanjay Patel <spatel@rotateright.com> | 2016-12-19 18:35:37 +0000 |
| commit | 5a443ac000c667302135f0c4735cb3c98bac1763 (patch) | |
| tree | 76f81858aa7e6f1bd3d53e4d9366ef6e8c608a97 /llvm/test/Transforms | |
| parent | 05bf3ec4c48b0b9e4dc0d68cc975e6987228411e (diff) | |
| download | bcm5719-llvm-5a443ac000c667302135f0c4735cb3c98bac1763.tar.gz bcm5719-llvm-5a443ac000c667302135f0c4735cb3c98bac1763.zip | |
[InstCombine] use commutative matcher for pattern with commutative operators
This is a case that was missed in:
https://reviews.llvm.org/rL290067
...and it would regress if we fix operand complexity (PR28296).
llvm-svn: 290127
Diffstat (limited to 'llvm/test/Transforms')
| -rw-r--r-- | llvm/test/Transforms/InstCombine/or.ll | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/llvm/test/Transforms/InstCombine/or.ll b/llvm/test/Transforms/InstCombine/or.ll index facd63019fe..2c9088428bd 100644 --- a/llvm/test/Transforms/InstCombine/or.ll +++ b/llvm/test/Transforms/InstCombine/or.ll @@ -596,7 +596,7 @@ define i32 @test42_commuted_xor(i32 %a, i32 %b) { ret i32 %or } -; Commute operands of the 'or'. +; (A & ~B) | (A ^ B) -> A ^ B define i32 @test43(i32 %a, i32 %b) { ; CHECK-LABEL: @test43( @@ -622,6 +622,9 @@ define i32 @test43_commuted_and(i32 %a, i32 %b) { ret i32 %or } +; Commute operands of the 'or'. +; (A ^ B) | (A & ~B) -> A ^ B + define i32 @test44(i32 %a, i32 %b) { ; CHECK-LABEL: @test44( ; CHECK-NEXT: [[OR:%.*]] = xor i32 %a, %b @@ -634,6 +637,18 @@ define i32 @test44(i32 %a, i32 %b) { ret i32 %or } +define i32 @test44_commuted_and(i32 %a, i32 %b) { +; CHECK-LABEL: @test44_commuted_and( +; CHECK-NEXT: [[OR:%.*]] = xor i32 %a, %b +; CHECK-NEXT: ret i32 [[OR]] +; + %xor = xor i32 %a, %b + %neg = xor i32 %b, -1 + %and = and i32 %neg, %a + %or = or i32 %xor, %and + ret i32 %or +} + define i32 @test45(i32 %x, i32 %y, i32 %z) { ; CHECK-LABEL: @test45( ; CHECK-NEXT: [[TMP1:%.*]] = and i32 %x, %z |

