diff options
| author | George Burgess IV <george.burgess.iv@gmail.com> | 2018-04-24 00:25:01 +0000 |
|---|---|---|
| committer | George Burgess IV <george.burgess.iv@gmail.com> | 2018-04-24 00:25:01 +0000 |
| commit | 8e807bf3fa4157ef16b314c1b0d0e5ddc2c3de88 (patch) | |
| tree | c8a58c326bc1dca51bd817ac93c9dabdf2e8acc5 /llvm/test/Transforms/InstSimplify/select.ll | |
| parent | cf30f6425a667dc1656588a8248c9a9d13366990 (diff) | |
| download | bcm5719-llvm-8e807bf3fa4157ef16b314c1b0d0e5ddc2c3de88.tar.gz bcm5719-llvm-8e807bf3fa4157ef16b314c1b0d0e5ddc2c3de88.zip | |
Reland r301880(!): "[InstSimplify] Handle selects of GEPs with 0 offset"
I was reminded today that this patch got reverted in r301885. I can no
longer reproduce the failure that caused the revert locally (...almost
one year later), and the patch applied pretty cleanly, so I guess we'll
see if the bots still get angry about it.
The original breakage was InstSimplify complaining (in "assertion
failed" form) about getting passed some crazy IR when running `ninja
check-sanitizer`. I'm unable to find traces of what, exactly, said crazy
IR was. I suppose we'll find out pretty soon if that's still the case.
:)
Original commit:
Author: gbiv
Date: Mon May 1 18:12:08 2017
New Revision: 301880
URL: http://llvm.org/viewvc/llvm-project?rev=301880&view=rev
Log:
[InstSimplify] Handle selects of GEPs with 0 offset
In particular (since it wouldn't fit nicely in the summary):
(select (icmp eq V 0) P (getelementptr P V)) -> (getelementptr P V)
Differential Revision: https://reviews.llvm.org/D31435
llvm-svn: 330667
Diffstat (limited to 'llvm/test/Transforms/InstSimplify/select.ll')
| -rw-r--r-- | llvm/test/Transforms/InstSimplify/select.ll | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/llvm/test/Transforms/InstSimplify/select.ll b/llvm/test/Transforms/InstSimplify/select.ll index c4df76d4535..d640805f86b 100644 --- a/llvm/test/Transforms/InstSimplify/select.ll +++ b/llvm/test/Transforms/InstSimplify/select.ll @@ -545,3 +545,22 @@ define i8 @do_not_assume_sel_cond(i1 %cond, i8 %x, i8 %y) { ret i8 %sel } +define i32* @select_icmp_eq_0_gep_operand(i32* %base, i64 %n) { +; CHECK-LABEL: @select_icmp_eq_0_gep_operand( +; CHECK-NEXT: [[GEP:%.*]] = getelementptr +; CHECK-NEXT: ret i32* [[GEP]] + %cond = icmp eq i64 %n, 0 + %gep = getelementptr i32, i32* %base, i64 %n + %r = select i1 %cond, i32* %base, i32* %gep + ret i32* %r +} + +define i32* @select_icmp_ne_0_gep_operand(i32* %base, i64 %n) { +; CHECK-LABEL: @select_icmp_ne_0_gep_operand( +; CHECK-NEXT: [[GEP:%.*]] = getelementptr +; CHECK-NEXT: ret i32* [[GEP]] + %cond = icmp ne i64 %n, 0 + %gep = getelementptr i32, i32* %base, i64 %n + %r = select i1 %cond, i32* %gep, i32* %base + ret i32* %r +} |

